From c9125a011118f49b65205a7bb04fc353ab3a54ee Mon Sep 17 00:00:00 2001 From: CorwinDev <88144943+CorwinDev@users.noreply.github.com> Date: Tue, 13 Dec 2022 20:22:24 +0100 Subject: [PATCH] Some bug fixes --- src/commands/casino/blackjack.js | 2 +- src/commands/casino/crash.js | 224 +++++++++++------------ src/commands/casino/slots.js | 2 +- src/commands/developers/servers.js | 2 +- src/commands/developers/whitelist.js | 49 ----- src/events/channel/channelCreate.js | 20 +- src/events/channel/channelDelete.js | 21 +-- src/events/channel/channelNameUpdate.js | 19 +- src/events/channel/channelPinsUpdate.js | 19 +- src/events/channel/channelTopicUpdate.js | 19 +- src/events/thread/threadCreate.js | 6 +- src/events/thread/threadDelete.js | 6 +- src/events/thread/threadUpdate.js | 6 +- src/handlers/components/embed.js | 2 +- src/interactions/Command/developers.js | 24 +-- 15 files changed, 176 insertions(+), 245 deletions(-) delete mode 100644 src/commands/developers/whitelist.js diff --git a/src/commands/casino/blackjack.js b/src/commands/casino/blackjack.js index f32e904..28cccbc 100644 --- a/src/commands/casino/blackjack.js +++ b/src/commands/casino/blackjack.js @@ -7,7 +7,7 @@ module.exports = async (client, interaction, args) => { Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { if (data) { - let money = parseInt(args[0]); + let money = parseInt(interaction.options.getNumber('amount')); if (!money) return client.errUsage({ usage: "blackjack [amount]", type: 'editreply' }, interaction); if (money > data.Money) return client.errNormal({ error: `You are betting more than you have!`, type: 'editreply' }, interaction); diff --git a/src/commands/casino/crash.js b/src/commands/casino/crash.js index 3dca718..612a6b1 100644 --- a/src/commands/casino/crash.js +++ b/src/commands/casino/crash.js @@ -4,142 +4,142 @@ const Schema = require("../../database/models/economy"); module.exports = async (client, interaction, args) => { let user = interaction.user; - var result = Math.ceil(Math.random() * 12); + var result = Math.ceil(Math.random() * 12); - Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { - if (data) { - let money = parseInt(args[0]); - if (!money) return client.errUsage({ usage: "crash [amount]", type: 'editreply' }, interaction); + Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { + if (data) { + let money = parseInt(interaction.options.getNumber('amount')); + if (!money) return client.errUsage({ usage: "crash [amount]", type: 'editreply' }, interaction); - if (money > data.Money) return client.errNormal({ error: `You are betting more than you have!`, type: 'editreply' }, interaction); + if (money > data.Money) return client.errNormal({ error: `You are betting more than you have!`, type: 'editreply' }, interaction); - const row = new Discord.ActionRowBuilder() - .addComponents( - new Discord.ButtonBuilder() - .setCustomId('crash_stop') - .setEmoji("🛑") - .setStyle(Discord.ButtonStyle.Danger), - ) + const row = new Discord.ActionRowBuilder() + .addComponents( + new Discord.ButtonBuilder() + .setCustomId('crash_stop') + .setEmoji("🛑") + .setStyle(Discord.ButtonStyle.Danger), + ) - const disableRow = new Discord.ActionRowBuilder() - .addComponents( - new Discord.ButtonBuilder() - .setCustomId('crash_stop') - .setEmoji("🛑") - .setStyle(Discord.ButtonStyle.Danger) - .setDisabled(true), - ) + const disableRow = new Discord.ActionRowBuilder() + .addComponents( + new Discord.ButtonBuilder() + .setCustomId('crash_stop') + .setEmoji("🛑") + .setStyle(Discord.ButtonStyle.Danger) + .setDisabled(true), + ) - client.embed({ - desc: `Crash started by ${user}・React 🛑 to stop`, - fields: [ - { - name: `Multiplier`, - value: `1x`, - inline: true, - }, - { - name: `Profit`, - value: `**0**`, - inline: true, - } - ], - components: [row], - type: 'editreply' - }, interaction).then(msg => { - let multiplier = 1; - let index = 0; + client.embed({ + desc: `Crash started by ${user}・React 🛑 to stop`, + fields: [ + { + name: `Multiplier`, + value: `1x`, + inline: true, + }, + { + name: `Profit`, + value: `**0**`, + inline: true, + } + ], + components: [row], + type: 'editreply' + }, interaction).then(msg => { + let multiplier = 1; + let index = 0; - let times = result + 1; - let timer = 2000 * times; + let times = result + 1; + let timer = 2000 * times; - setInterval(() => { - if (index === result + 1) { return } - else if (index === result) { + setInterval(() => { + if (index === result + 1) { return } + else if (index === result) { + + Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { + if (data) { + data.Money -= money; + data.save(); + } + }) + + return client.embed({ + title: `Crash Results of ${user}`, + desc: `${msg}`, + type: 'edit', + fields: [ + { + name: `Loss`, + value: `**${money}**`, + inline: false, + } + ] + }, msg) + + } + else { + index += 1; + multiplier += 0.20; + + let calc = money * multiplier; + let profit = calc - money; + + client.embed({ + desc: `Crash started by ${user}・React 🛑 to stop`, + type: 'edit', + fields: [ + { + name: `Multiplier`, + value: `${multiplier.toFixed(1)}x`, + inline: true, + }, + { + name: `Profit`, + value: `**$${profit.toFixed(2)}**`, + inline: true, + } + ], + components: [row] + }, msg) + } + }, 2000) + + const filter = i => i.user.id === interaction.user.id; + interaction.channel.awaitMessageComponent({ filter, max: 1, time: timer }) + .then(async i => { + if (i.customId == "crash_stop") { + i.deferUpdate(); + + index = result + 1; Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { if (data) { - data.Money -= money; + data.Money += parseInt(profit); data.save(); } }) return client.embed({ - title: `Crash Results of ${user}`, - desc: `${f} \n${msg}`, + desc: `Crash Results of ${user}`, edit: true, fields: [ - { - name: `Loss`, - value: `**${money}**`, - inline: false, - } - ] - }, msg) - - } - else { - index += 1; - multiplier += 0.20; - - let calc = money * multiplier; - let profit = calc - money; - - client.embed({ - desc: `Crash started by ${user}・React 🛑 to stop`, - edit: true, - fields: [ - { - name: `Multiplier`, - value: `${multiplier.toFixed(1)}x`, - inline: true, - }, { name: `Profit`, value: `**$${profit.toFixed(2)}**`, - inline: true, + inline: false, } ], - components: [row] + components: [disableRow] }, msg) - const filter = i => i.user.id === interaction.user.id; - interaction.channel.awaitMessageComponent({ filter, max: 1, time: timer }) - .then(async i => { - if (i.customId == "crash_stop") { - i.deferUpdate(); - - index = result + 1; - - Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { - if (data) { - data.Money += parseInt(profit); - data.save(); - } - }) - - return client.embed({ - desc: `Crash Results of ${user}`, - edit: true, - fields: [ - { - name: `Profit`, - value: `**$${profit.toFixed(2)}**`, - inline: false, - } - ], - components: [disableRow] - }, msg) - - } - }) } - }, 2000) - }) + }) + }) - } - else { - client.errNormal({ error: `You has no ${client.emotes.economy.coins}!`, type: 'editreply' }, interaction); - } - }) + } + else { + client.errNormal({ error: `You has no ${client.emotes.economy.coins}!`, type: 'editreply' }, interaction); + } + }) } \ No newline at end of file diff --git a/src/commands/casino/slots.js b/src/commands/casino/slots.js index 14e6944..6d10260 100644 --- a/src/commands/casino/slots.js +++ b/src/commands/casino/slots.js @@ -9,7 +9,7 @@ module.exports = async (client, interaction, args) => { Schema.findOne({ Guild: interaction.guild.id, User: user.id }, async (err, data) => { if (data) { - let money = parseInt(args[0]); + let money = parseInt(interaction.options.getNumber('amount')); let win = false; if (!money) return client.errUsage({ usage: "slots [amount]", type: 'editreply' }, interaction); diff --git a/src/commands/developers/servers.js b/src/commands/developers/servers.js index 3a2ab4b..540e3e3 100644 --- a/src/commands/developers/servers.js +++ b/src/commands/developers/servers.js @@ -7,7 +7,7 @@ module.exports = async (client, interaction, args) => { }) const output = new Discord.AttachmentBuilder(Buffer.from(list), { name: 'servers.txt'}); - interaction.editreply({ files: [output] }); + interaction.editReply({ files: [output] }); } \ No newline at end of file diff --git a/src/commands/developers/whitelist.js b/src/commands/developers/whitelist.js deleted file mode 100644 index 482a7f5..0000000 --- a/src/commands/developers/whitelist.js +++ /dev/null @@ -1,49 +0,0 @@ -const Discord = require('discord.js'); - -const Schema = require('../../database/models/whitelist'); - -module.exports = async (client, interaction, args) => { - const type = interaction.options.getString('type'); - const guild = interaction.options.getString('guild'); - - if (interaction.author.id === "534398298002292739") { - if (type == "add") { - Schema.findOne({ Guild: guild }, async (err, data) => { - if (data) { - data.Guild = guild; - data.save(); - } - else { - new Schema({ - Guild: guild - }).save(); - } - }) - - client.succNormal({ - text: `${guild} added to the bot whitelist`, - type: 'editreply' - }, interaction); - } - else if (type == "remove") { - Schema.findOne({ Guild: guild }, async (err, data) => { - if (data) { - Schema.findOneAndDelete({ Guild: guild }).then(() => { - client.succNormal({ - text: `${guild} removed from the bot whitelist`, - type: 'editreply' - }, interaction); - }) - } - }) - } - } - else { - client.errNormal({ - error: "Only the Bot CEO are allowed to do this", - type: 'editreply' - }, interaction); - } -} - - \ No newline at end of file diff --git a/src/events/channel/channelCreate.js b/src/events/channel/channelCreate.js index b371130..1395e74 100644 --- a/src/events/channel/channelCreate.js +++ b/src/events/channel/channelCreate.js @@ -2,21 +2,21 @@ const discord = require('discord.js'); module.exports = async (client, channel) => { let types = { - GUILD_TEXT: "Text Channel", - GUILD_VOICE: "Voice Channel", - GUILD_CATEGORY: "Category", - UNKNOWN: "No Type", - GUILD_NEWS: "News Channel", - GUILD_STAGE_VOICE: "Stage Channel", - GUILD_STORE: "Store Channel", - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 0: "Text Channel", + 2: "Voice Channel", + 4: "Category", + 5: "News Channel", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", + 13: "Stage Channel", + 14: "Category", } const logsChannel = await client.getLogs(channel.guild.id); if (!logsChannel) return; + console.log(channel.type) client.embed({ title: `🔧・Channel created`, desc: `A channel has been created`, diff --git a/src/events/channel/channelDelete.js b/src/events/channel/channelDelete.js index 8c0a661..67c98cf 100644 --- a/src/events/channel/channelDelete.js +++ b/src/events/channel/channelDelete.js @@ -4,18 +4,17 @@ const ticketChannels = require("../../database/models/ticketChannels"); module.exports = async (client, channel) => { let types = { - GUILD_TEXT: "Text Channel", - GUILD_VOICE: "Voice Channel", - GUILD_CATEGORY: "Category", - UNKNOWN: "No Type", - GUILD_NEWS: "News Channel", - GUILD_STAGE_VOICE: "Stage Channel", - GUILD_STORE: "Store Channel", - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 0: "Text Channel", + 2: "Voice Channel", + 4: "Category", + 5: "News Channel", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", + 13: "Stage Channel", + 14: "Category", } - + const logsChannel = await client.getLogs(channel.guild.id); if (!logsChannel) return; diff --git a/src/events/channel/channelNameUpdate.js b/src/events/channel/channelNameUpdate.js index b7985a7..d33c45a 100644 --- a/src/events/channel/channelNameUpdate.js +++ b/src/events/channel/channelNameUpdate.js @@ -2,16 +2,15 @@ const discord = require('discord.js'); module.exports = async (client, channel, oldName, newName) => { let types = { - GUILD_TEXT: "Text Channel", - GUILD_VOICE: "Voice Channel", - GUILD_CATEGORY: "Category", - UNKNOWN: "No Type", - GUILD_NEWS: "News Channel", - GUILD_STAGE_VOICE: "Stage Channel", - GUILD_STORE: "Store Channel", - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 0: "Text Channel", + 2: "Voice Channel", + 4: "Category", + 5: "News Channel", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", + 13: "Stage Channel", + 14: "Category", } const logsChannel = await client.getLogs(channel.guild.id); diff --git a/src/events/channel/channelPinsUpdate.js b/src/events/channel/channelPinsUpdate.js index 34a997d..f33f261 100644 --- a/src/events/channel/channelPinsUpdate.js +++ b/src/events/channel/channelPinsUpdate.js @@ -2,16 +2,15 @@ const discord = require('discord.js'); module.exports = async (client, channel, time) => { let types = { - GUILD_TEXT: "Text Channel", - GUILD_VOICE: "Voice Channel", - GUILD_CATEGORY: "Category", - UNKNOWN: "No Type", - GUILD_NEWS: "News Channel", - GUILD_STAGE_VOICE: "Stage Channel", - GUILD_STORE: "Store Channel", - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 0: "Text Channel", + 2: "Voice Channel", + 4: "Category", + 5: "News Channel", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", + 13: "Stage Channel", + 14: "Category", } const logsChannel = await client.getLogs(channel.guild.id); diff --git a/src/events/channel/channelTopicUpdate.js b/src/events/channel/channelTopicUpdate.js index fea8a70..68e3329 100644 --- a/src/events/channel/channelTopicUpdate.js +++ b/src/events/channel/channelTopicUpdate.js @@ -2,16 +2,15 @@ const discord = require('discord.js'); module.exports = async (client, channel, oldTopic, newTopic) => { let types = { - GUILD_TEXT: "Text Channel", - GUILD_VOICE: "Voice Channel", - GUILD_CATEGORY: "Category", - UNKNOWN: "No Type", - GUILD_NEWS: "News Channel", - GUILD_STAGE_VOICE: "Stage Channel", - GUILD_STORE: "Store Channel", - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 0: "Text Channel", + 2: "Voice Channel", + 4: "Category", + 5: "News Channel", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", + 13: "Stage Channel", + 14: "Category", } const logsChannel = await client.getLogs(channel.guild.id); diff --git a/src/events/thread/threadCreate.js b/src/events/thread/threadCreate.js index aa813c0..b443c30 100644 --- a/src/events/thread/threadCreate.js +++ b/src/events/thread/threadCreate.js @@ -2,9 +2,9 @@ const discord = require('discord.js'); module.exports = async (client, channel) => { let types = { - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", } const logsChannel = await client.getLogs(channel.guild.id); diff --git a/src/events/thread/threadDelete.js b/src/events/thread/threadDelete.js index 80c6d66..387b7c4 100644 --- a/src/events/thread/threadDelete.js +++ b/src/events/thread/threadDelete.js @@ -2,9 +2,9 @@ const discord = require('discord.js'); module.exports = async (client, channel) => { let types = { - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", } const logsChannel = await client.getLogs(channel.guild.id); diff --git a/src/events/thread/threadUpdate.js b/src/events/thread/threadUpdate.js index 8a319aa..dc7c10a 100644 --- a/src/events/thread/threadUpdate.js +++ b/src/events/thread/threadUpdate.js @@ -2,9 +2,9 @@ const discord = require('discord.js'); module.exports = async (client, oldChannel, newChannel) => { let types = { - GUILD_NEWS_THREAD: "News Thread", - GUILD_PUBLIC_THREAD: "Public Thread", - GUILD_PRIVATE_THREAD: "Private Thread", + 10: "News Thread", + 11: "Public Thread", + 12: "Private Thread", } const logsChannel = await client.getLogs(newChannel.guild.id); diff --git a/src/handlers/components/embed.js b/src/handlers/components/embed.js index d92f1be..f72c4a3 100644 --- a/src/handlers/components/embed.js +++ b/src/handlers/components/embed.js @@ -308,7 +308,7 @@ module.exports = (client) => { }).catch(e => { }); } else { - return await interaction.send({ + return await interaction.channel.send({ embeds: embeds, content: content, components: components, diff --git a/src/interactions/Command/developers.js b/src/interactions/Command/developers.js index b1a75b8..f59897d 100644 --- a/src/interactions/Command/developers.js +++ b/src/interactions/Command/developers.js @@ -74,21 +74,6 @@ module.exports = { .setName('servers') .setDescription('See all servers from this shard') ) - .addSubcommand(subcommand => - subcommand - .setName('whitelist') - .setDescription('Manage the bot whitelist') - .addStringOption(option => - option.setName('type') - .setDescription('The type of whitelist') - .setRequired(true) - .addChoices( - { name: 'Add', value: 'add' }, - { name: 'Remove', value: 'remove' } - ) - ) - .addStringOption(option => option.setName('guild').setDescription('The ID of a guild').setRequired(true)) - ) , /** @@ -102,11 +87,10 @@ module.exports = { if (data && data.FLAGS.includes("DEVELOPER")) { client.loadSubcommands(client, interaction, args); } else { - console.log(`[ERROR] >> Only Bot developers are allowed to do this`); - client.errNormal({ - error: "Only Bot developers are allowed to do this", - type: 'reply' - }, interaction); + return client.errNormal({ + error: 'Only Bot developers are allowed to do this', + type: 'editreply' + }, interaction) } }) },