Skip to content

Commit

Permalink
Dev (#91)
Browse files Browse the repository at this point in the history
* Fix help

Co-Authored-By: Finn Kötting <69923589+finnkoetting@users.noreply.github.com>

* feat: wwyd replay button

* Resolve minor bigs

* Error Catch

* Remove some questions

* Delete replay.js

* Remove vote buttons to cooldown

* Change leave color

* Add truth or dare template

* Added Replay Channels

* Added Replay Channels

* Fixed wording

* Update interactionCreate.js

* remove nhie from dailymessage

* Switch to d.js v14.11

* Fixed wyCustom

* Delete Daily Role

* Fixed button display

* edit: info cmd

* update: names info cmd

* fix: dailyMessage

Co-Authored-By: ForGetFulSkyBro <47897305+forgetfulskybro@users.noreply.github.com>
Co-Authored-By: SpaceDev <75725016+thespacedev@users.noreply.github.com>

* fix: dailyMsg regular

* rem: dare command

* feat: welcome message translatio n

* remove: truth command

* rename: custom

* feat: type command (Unfinished)

* fix: missing example img

* add: missing devs

* Added guide image

* impr: cache system

* Added welcome tests & types

* Fixed default cooldown

* add: translations

---------

Co-authored-by: Finn Kötting <69923589+finnkoetting@users.noreply.github.com>
Co-authored-by: ForGetFulSkyBro <forgetfulskybro9@gmail.com>
Co-authored-by: Dominik K <dominik+github@wouldyoubot.com>
Co-authored-by: Would You <136710848+WouldYouGG@users.noreply.github.com>
Co-authored-by: ForGetFulSkyBro <47897305+forgetfulskybro@users.noreply.github.com>
Co-authored-by: SpaceDev <75725016+thespacedev@users.noreply.github.com>
  • Loading branch information
7 people authored Jul 16, 2023
1 parent 9e8eac3 commit b9b2c12
Show file tree
Hide file tree
Showing 45 changed files with 8,216 additions and 8,196 deletions.
10,886 changes: 5,201 additions & 5,685 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/buttons/dailyInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
description: "Daily Interval customization",
},
async execute(interaction, client, guildDb) {
interaction.showModal(modalObject).catch(() => { })
interaction.showModal(modalObject)
interaction.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
Expand Down
23 changes: 20 additions & 3 deletions src/buttons/dailyRole.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
const { ActionRowBuilder, RoleSelectMenuBuilder } = require('discord.js');
const { ActionRowBuilder, RoleSelectMenuBuilder, ButtonBuilder } = require('discord.js');
module.exports = {
data: {
name: 'dailyRole',
description: 'Daily Role',
},
async execute(interaction, client, guildDb) {

const inter = new ActionRowBuilder()
let inter;
let inter2;
if (guildDb?.dailyRole) {
inter = new ActionRowBuilder()
.addComponents(
new RoleSelectMenuBuilder()
.setCustomId('selectMenuRole')
.setPlaceholder('Select a role')
),
inter2 = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId('deleteDailyRole')
.setLabel('Delete Daily Role')
.setStyle('Danger')
)
} else {
inter = new ActionRowBuilder()
.addComponents(
new RoleSelectMenuBuilder()
.setCustomId('selectMenuRole')
.setPlaceholder('Select a role')
)
}

interaction.update({ embeds: [], content: client.translation.get(guildDb?.language, 'Settings.dailyRole'), components: [inter], ephemeral: true })
interaction.update({ embeds: [], content: client.translation.get(guildDb?.language, 'Settings.dailyRole'), components: guildDb?.dailyRole ? [inter, inter2] : [inter], ephemeral: true })
},
};
6 changes: 6 additions & 0 deletions src/buttons/dailyTimezone.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ module.exports = {
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyInterval'))
.setStyle("Primary")
.setEmoji("⏰")
),
dailyButtons3 = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("dailyThread")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyThread'))
.setStyle(guildDb.dailyThread ? "Success" : "Secondary"),
);

await client.database.updateGuild(interaction.guild.id, {
Expand Down
66 changes: 66 additions & 0 deletions src/buttons/deleteDailyRole.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
data: {
name: "deleteDailyRole",
description: "Delete Daily Role",
},
async execute(interaction, client, guildDb) {
const dailyMsgs = new EmbedBuilder()
.setTitle(client.translation.get(guildDb?.language, 'Settings.embed.dailyTitle'))
.setDescription(
`${client.translation.get(guildDb?.language, 'Settings.embed.dailyMsg')}: ${guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}\n${client.translation.get(guildDb?.language, 'Settings.embed.dailyChannel')}: ${guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
}\n${client.translation.get(guildDb?.language, 'Settings.embed.dailyRole')}: <:x_:1077962443013238814>\n${client.translation.get(guildDb?.language, 'Settings.embed.dailyTimezone')
}: ${guildDb.dailyTimezone}\n${client.translation.get(guildDb?.language, 'Settings.embed.dailyInterval')}: ${guildDb.dailyInterval
}\n${client.translation.get(guildDb?.language, 'Settings.embed.dailyType')}: ${guildDb.customTypes}`
)
.setColor("#0598F6");

const dailyButtons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("dailyMsg")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyMsg'))
.setStyle(guildDb.dailyMsg ? "Success" : "Secondary"),
new ButtonBuilder()
.setCustomId("dailyChannel")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyChannel'))
.setStyle(guildDb.dailyChannel ? "Success" : "Secondary"),
new ButtonBuilder()
.setCustomId("dailyType")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyType'))
.setStyle("Primary")
.setEmoji("📝")
),
dailyButtons2 = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("dailyTimezone")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyTimezone'))
.setStyle("Primary")
.setEmoji("🌍"),
new ButtonBuilder()
.setCustomId("dailyRole")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyRole'))
.setStyle("Secondary"),
new ButtonBuilder()
.setCustomId("dailyInterval")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.dailyInterval'))
.setStyle("Primary")
.setEmoji("⏰")
);

await client.database.updateGuild(interaction.guild.id, {
dailyRole: null,
});

return interaction.update({
content: null,
embeds: [dailyMsgs],
components: [dailyButtons, dailyButtons2],
ephemeral: true,
});
},
};
2 changes: 1 addition & 1 deletion src/buttons/neverhaveiever.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
.setCustomId(`neverhaveiever`)
]);

const time = guildDb?.voteCooldown ?? 60_000;
const time = 60_000;
const three_minutes = 3 * 60 * 1e3;


Expand Down
20 changes: 20 additions & 0 deletions src/buttons/replayChannels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { ActionRowBuilder, ChannelType, ChannelSelectMenuBuilder } = require('discord.js');
module.exports = {
data: {
name: 'replayChannels',
description: 'Replay Channels',
},
async execute(interaction, client, guildDb) {
if (guildDb.replayChannels.length >= 15) return interaction.reply({ content: client.translation.get(guildDb?.language, 'Settings.replayChannelLimit'), ephemeral: true })

const inter = new ActionRowBuilder()
.addComponents(
new ChannelSelectMenuBuilder()
.setCustomId('selectMenuReplay')
.setPlaceholder('Select a channel')
.addChannelTypes(ChannelType.GuildText)
)

interaction.update({ content: null, embeds: [], content: client.translation.get(guildDb?.language, 'Settings.replayChannel'), components: [inter], ephemeral: true })
},
};
50 changes: 50 additions & 0 deletions src/buttons/replayDelete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
data: {
name: "replayDelete",
description: "Replay Delete",
},
async execute(interaction, client, guildDb) {
const arr = guildDb.replayChannels.filter((c) => c.id !== interaction.values[0]).length > 0 ? guildDb.replayChannels : "None";

const generalMsg = new EmbedBuilder()
.setTitle(client.translation.get(guildDb?.language, 'Settings.embed.generalTitle'))
.setDescription(`${client.translation.get(guildDb?.language, 'Settings.embed.replayType')}: ${guildDb.replayType}\n ${client.translation.get(guildDb?.language, 'Settings.embed.replayChannels')}: ${arr === "None" ? arr : `\n${arr.filter((c) => c.id !== interaction.values[0]).map(c => `<#${c.id}>: ${c.cooldown}`).join("\n")}`}`)
.setColor("#0598F6")
.setFooter({
text: client.translation.get(guildDb?.language, 'Settings.embed.footer'),
iconURL: client.user.avatarURL(),
});

const generalButtons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("replayChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayCooldown'))
.setStyle(guildDb.replayCooldown ? "Success" : "Secondary"),
new ButtonBuilder()
.setCustomId("replayType")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayType'))
.setStyle("Primary")
.setEmoji("📝"),
);

const chanDelete = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("replayDeleteChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayDeleteChannels'))
.setStyle("Danger"),
);

guildDb.replayChannels = guildDb.replayChannels.filter((c) => c.id !== interaction.values[0]);
await client.database.updateGuild(interaction.guild.id, {
replayChannels: guildDb.replayChannels,
});

return interaction.update({
content: null,
embeds: [generalMsg],
components: [generalButtons, chanDelete],
ephemeral: true,
});
},
};
25 changes: 25 additions & 0 deletions src/buttons/replayDeleteChannels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { ActionRowBuilder, ChannelType, StringSelectMenuBuilder } = require('discord.js');
module.exports = {
data: {
name: 'replayDeleteChannels',
description: 'Replay Channels',
},
async execute(interaction, client, guildDb) {
if (guildDb.replayChannels.length <= 0) return interaction.reply({ content: client.translation.get(guildDb?.language, 'Settings.replayChannelNone'), ephemeral: true })
const inter = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId('replayDelete')
.setPlaceholder('Select a channel to remove cooldown from')
.addOptions(guildDb.replayChannels.map((channel) => {
return {
label: channel.name,
value: channel.id,
}
}))

)

interaction.update({ embeds: [], content: client.translation.get(guildDb?.language, 'Settings.replayChannel'), components: [inter], ephemeral: true })
},
};
49 changes: 49 additions & 0 deletions src/buttons/replayType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js");
module.exports = {
data: {
name: "replayType",
description: "Replay type",
},
async execute(interaction, client, guildDb) {
const newType = guildDb.replayType === "Channels" ? "Guild" : "Channels";
const generalMsg = new EmbedBuilder()
.setTitle(client.translation.get(guildDb?.language, 'Settings.embed.generalTitle'))
.setDescription(
`${client.translation.get(guildDb?.language, 'Settings.embed.replayType')}: ${newType}\n${guildDb.replayType === 'Channels' ? `${client.translation.get(guildDb?.language, 'Settings.embed.replayCooldown')}: ${guildDb.replayCooldown}` : `${client.translation.get(guildDb?.language, 'Settings.embed.replayChannels')}: ${guildDb.replayChannels.length > 0 ? `\n${guildDb.replayChannels.map(c => `<#${c.id}>: ${c.cooldown}`).join("\n")}` : client.translation.get(guildDb?.language, `Settings.embed.replayChannelsNone`)}`}`)
.setColor("#0598F6")
.setFooter({
text: client.translation.get(guildDb?.language, 'Settings.embed.footer'),
iconURL: client.user.avatarURL(),
});

const generalButtons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(guildDb.replayType === "Channels" ? "replayCooldown" : "replayChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayCooldown'))
.setStyle(guildDb.replayCooldown ? "Success" : "Secondary"),
new ButtonBuilder()
.setCustomId("replayType")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayType'))
.setStyle("Primary")
.setEmoji("📝"),
);

const chanDelete = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("replayDeleteChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayDeleteChannels'))
.setStyle("Danger"),
);

await client.database.updateGuild(interaction.guild.id, {
replayType: newType
});

return interaction.update({
content: null,
embeds: [generalMsg],
components: newType === "Channels" ? [generalButtons, chanDelete] : [generalButtons],
ephemeral: true,
});
},
};
98 changes: 98 additions & 0 deletions src/buttons/selectMenuReplay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const { ButtonBuilder, ActionRowBuilder, EmbedBuilder } = require("discord.js");
const modalObject = {
title: "Replay Cooldown",
custom_id: "replaymodal",
components: [
{
type: 1,
components: [
{
type: 4,
style: 1,
custom_id: "input",
label: "Provide a replay cooldown in milliseconds",
},
],
},
],
};

function isNumericRegex(str) {
return /^[0-9]+$/.test(str); // regex for extra 0,00000002% speeds :trol:
}
module.exports = {
data: {
name: "selectMenuReplay",
description: "Select Menu Replay",
},
async execute(interaction, client, guildDb) {
if (guildDb.replayChannels.find((c) => c.id === interaction.values[0])) return interaction.reply({ content: client.translation.get(guildDb?.language, 'Settings.replayChannelAlready'), ephemeral: true })

interaction.showModal(modalObject)
interaction.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
})
.then(async (modalInteraction) => {
const value = modalInteraction.components[0].components[0].value;
if (isNumericRegex(value) === false)
return modalInteraction.reply({
ephemeral: true,
content: client.translation.get(guildDb?.language, 'Settings.cooldownInvalid'),
});

if (value < 2000) return modalInteraction.reply({
ephemeral: true,
content: client.translation.get(guildDb?.language, 'Settings.cooldownMin'),
});

if (value > 21600000)
return modalInteraction.reply({
ephemeral: true,
content: client.translation.get(guildDb?.language, 'Settings.cooldownTooLong')
});

const arr = guildDb.replayChannels.length > 0 ? [{ id: interaction.values[0], cooldown: value }].concat(guildDb.replayChannels) : [{ id: interaction.values[0], cooldown: value }];

const generalMsg = new EmbedBuilder()
.setTitle(client.translation.get(guildDb?.language, 'Settings.embed.generalTitle'))
.setDescription(`${client.translation.get(guildDb?.language, 'Settings.embed.replayType')}: ${guildDb.replayType}\n ${client.translation.get(guildDb?.language, 'Settings.embed.replayChannels')}:\n${arr.map(c => `<#${c.id}>: ${c.cooldown}`).join("\n")}`)
.setColor("#0598F6")
.setFooter({
text: client.translation.get(guildDb?.language, 'Settings.embed.footer'),
iconURL: client.user.avatarURL(),
});

const generalButtons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("replayChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayCooldown'))
.setStyle(guildDb.replayCooldown ? "Success" : "Secondary"),
new ButtonBuilder()
.setCustomId("replayType")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayType'))
.setStyle("Primary")
.setEmoji("📝"),
);

const chanDelete = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("replayDeleteChannels")
.setLabel(client.translation.get(guildDb?.language, 'Settings.button.replayDeleteChannels'))
.setStyle("Danger"),
);

const channel = client.channels.cache.get(interaction.values[0])
guildDb.replayChannels.push({ id: interaction.values[0], cooldown: value, name: channel.name.slice(0, 25) });
await client.database.updateGuild(interaction.guild.id, {
replayChannels: guildDb.replayChannels,
});
return modalInteraction.update({
content: null,
embeds: [generalMsg],
components: [generalButtons, chanDelete],
ephemeral: true,
});
}).catch((e) => { console.log(e) })
},
};
Loading

0 comments on commit b9b2c12

Please sign in to comment.