diff --git a/source/commands/developer/ping.js b/source/commands/developer/ping.js index 05e15d80..15261e37 100644 --- a/source/commands/developer/ping.js +++ b/source/commands/developer/ping.js @@ -1,38 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "ping", "description": "Check the ping and api latency of the bot.", "category": "developer", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "ping", - "aliases": ["ปิง", "การเชื่อมต่อ"], - async execute(client, message, args) { - const msg = await message.channel.send(client.translate.commands.ping.waiting); - const ping = Math.round((msg.createdTimestamp - message.createdTimestamp) - client.ws.ping); - const api = Math.round(client.ws.ping); - const pingEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.ping.connection) - .setDescription(client.translate.commands.ping.info.replace("%s1", ping).replace("%s2", api)) - - msg.edit({ - "content": client.translate.commands.ping.result, - "embeds": [pingEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/developer/reload.js b/source/commands/developer/reload.js index 43dabe5d..c6e1ef48 100644 --- a/source/commands/developer/reload.js +++ b/source/commands/developer/reload.js @@ -3,58 +3,20 @@ const { readdirSync } = require("node:fs"); const path = require("path"); module.exports = { + "enable": true, "name": "reload", "description": "Reload the command that doesn't work.", "category": "developer", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "reload ", - "aliases": ["recommand", "รีโหลด", "โหลดซ้ำ"], - async execute(client, message, args) { - const inputCommand = args[0]; - - if (!inputCommand) return message.reply(client.translate.commands.reload.command_required); - - const commandName = inputCommand.toLowerCase(); - const commands = message.client.commands.get(commandName); - const aliases = message.client.commands.get(client.aliases.get(commandName)); - const command = commands || aliases; - - if (!command) return message.reply(client.translate.commands.reload.invalid_command); - - readdirSync(path.join(__dirname, "..")).forEach(async (dirs) => { - const files = readdirSync(path.join(__dirname, "..", dirs)); - - if (files.includes(commandName + ".js")) { - const file = "../" + dirs + "/" + commandName + ".js"; - - try { - delete require.cache[require.resolve(file)]; - client.commands.delete(commandName); - - const pull = require(file); - - client.commands.set(commandName, pull); - message.channel.send(client.translate.commands.reload.reloaded.replace("%s", commandName)); - } catch (error) { - message.channel.send(client.translate.commands.reload.reload_error.replace("%s", inputCommand.toUpperCase())); - console.log(error.stack || error); - } - } - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/developer/system.js b/source/commands/developer/system.js index 358a1be1..bd1187de 100644 --- a/source/commands/developer/system.js +++ b/source/commands/developer/system.js @@ -3,173 +3,20 @@ const { version } = require("discord.js"); const { get } = require("systeminformation"); module.exports = { + "enable": true, "name": "system", "description": "Get system operating status and more", "category": "developer", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "system", - "aliases": ["sys", "systeminfo", "ระบบ"], - async execute(client, message, args) { - const msg = await message.channel.send(client.translate.commands.system.loading); - - get({ - "time": "uptime", - "system": "manufacturer, model", - "bios": "vendor, version, releaseDate", - "cpu": "manufacturer, brand, speed, cores, physicalCores", - "cpuTemperature": "main", - "mem": "total, used", - "battery": "hasBattery, isCharging, percent, type", - "graphics": "controllers, displays", - "osInfo": "platform, arch" - }).then((data) => { - const serverSeconds = (data.time.uptime / 1000); - const serverDays = Math.floor(serverSeconds / (3600 * 24)); - const serverHours = Math.floor(serverSeconds % (3600 * 24) / 3600); - - const systemManufacturer = data.system.manufacturer; - const systemModel = data.system.model; - - const biosVendor = data.bios.vendor; - const biosVersion = data.bios.version; - const biosReleaseDate = data.bios.releaseDate; - - const cpuManufacturer = data.cpu.manufacturer; - const cpuBrand = data.cpu.brand; - const cpuSpeed = data.cpu.speed; - const cpuCores = data.cpu.cores; - const cpuPhysicalCores = data.cpu.physicalCores; - - const cpuTempMain = data.cpuTemperature.cpuTempMain; - - const memUsed = (data.mem.used / 1024 / 1024).toFixed(2); - const memTotal = (data.mem.total / 1024 / 1024).toFixed(2); - - const batteryHasBattery = data.battery.hasBattery; - const batteryIsCharging = data.battery.isCharging; - const batteryPercent = data.battery.percent; - const batteryType = data.battery.type; - - const gpuControllers = data.graphics.controllers; - const gpuControllersLength = gpuControllers.length; - let gpuMain = "", - gpuMainModel = "", - gpuMainFanSpeed = "", - gpuMainMemoryTotal = "", - gpuMainMemoryUsed = "", - gpuMainTemperatureGpu = ""; - for (let i = 0; i < gpuControllersLength; i++) { - gpuMainModel = gpuControllers[i].model; - gpuMainFanSpeed = gpuControllers[i].fanSpeed; - gpuMainMemoryTotal = gpuControllers[i].memoryTotal; - gpuMainMemoryUsed = gpuControllers[i].memoryUsed; - gpuMainTemperatureGpu = gpuControllers[i].temperatureGpu; - - gpuMain += ("```" + gpuMainModel + ", " + (gpuMainMemoryUsed ? (gpuMainMemoryTotal ? (gpuMainMemoryUsed + "/" + gpuMainMemoryTotal + "MB") : "") : "") + (gpuMainFanSpeed ? gpuMainFanSpeed + " " : "") + (gpuMainTemperatureGpu ? gpuMainTemperatureGpu : "") + "```"); - } - - const gpuDisplays = data.graphics.displays; - const gpuDisplaysLength = gpuDisplays.length; - let gpuSecond = "", - gpuSecondModel = "", - gpuSecondMain = ""; - for (let i = 0; i < gpuDisplaysLength; i++) { - gpuSecondModel = gpuDisplays[i].model; - gpuSecondMain = gpuDisplays[i].main; - - gpuSecond += ("```" + gpuSecondModel + ", " + (gpuSecondMain ? client.translate.commands.system.main : "") + "```"); - } - - const osPlatform = data.osInfo.platform; - const osArch = data.osInfo.arch; - - const clientColor = message.guild.members.me.displayHexColor; - const systemEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.system.info_title) - .setDescription(client.translate.commands.system.info_description) - .setColor(clientColor) - .addFields([ - { - "name": "• Discord.js", - "value": "```" + "v" + version + "```", - "inline": true - }, - { - "name": "• Node.js", - "value": "```" + process.version + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_uptime.title, - "value": "```" + client.translate.commands.system.info_uptime.info.replace("%s1", serverDays).replace("%s2", serverHours) + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_system, - "value": "```" + (systemManufacturer ? (systemManufacturer + " " + systemModel) : client.translate.commands.system.unknown) + "```", - "inline": true - }, - { - "name": "• BIOS", - "value": "```" + (biosVendor ? (biosVendor + " " + biosVersion + ", " + biosReleaseDate) : client.translate.commands.system.unknown) + "```", - "inline": true - }, - { - "name": "• CPU", - "value": "```" + (cpuManufacturer ? (cpuManufacturer + " " + cpuBrand + ", " + cpuSpeed + "GHz " + cpuCores + " Cores " + cpuPhysicalCores + " Trades") : client.translate.commands.system.unknown) + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_temperature, - "value": "```" + (cpuTempMain || client.translate.commands.system.unknown) + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_memory_used, - "value": "```" + (memUsed && memTotal ? (memUsed + " / " + memTotal + "MB") : client.translate.commands.system.unknown) + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_battery.title, - "value": "```" + (batteryHasBattery ? (batteryIsCharging ? (client.translate.commands.system.info_battery.charging + " " + batteryPercent + ", " + batteryType || client.translate.commands.system.unknown) : client.translate.commands.system.info_battery.charging + " " + batteryPercent + ", " + batteryType || client.translate.commands.system.unknown) : client.translate.commands.system.info_battery.without) + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_gpu_control, - "value": gpuMain || "```" + client.translate.commands.system.unknown + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_gpu_display, - "value": gpuSecond || "```" + client.translate.commands.system.unknown + "```", - "inline": true - }, - { - "name": client.translate.commands.system.info_platform, - "value": "```" + (osPlatform ? (osPlatform + " " + osArch) : client.translate.commands.system.unknown) + "```", - "inline": true - } - ]); - - msg.edit({ - "content": null, - "embeds": [systemEmbed] - }); - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -330,4 +177,4 @@ module.exports.interaction.slash = { }); }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/developer/uptime.js b/source/commands/developer/uptime.js index 72541b1c..30caabaf 100644 --- a/source/commands/developer/uptime.js +++ b/source/commands/developer/uptime.js @@ -1,46 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "uptime", "description": "Displays the bots current uptime!", "category": "developer", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "uptime", - "aliases": ["uptimes", "เวลา"], - async execute(client, message, args) { - const ms = client.uptime; - const sec = Math.floor((ms / 1000) % 60).toString(); - const min = Math.floor((ms / (1000 * 60)) % 60).toString(); - const hrs = Math.floor((ms / (1000 * 60 * 60)) % 60).toString(); - const days = Math.floor((ms / (1000 * 60 * 60 * 24)) % 60).toString(); - const duration = days.padStart(1, "0") + " " + client.translate.commands.uptime.days + " " + - hrs.padStart(2, "0") + " " + client.translate.commands.uptime.hours + " " + - min.padStart(2, "0") + " " + client.translate.commands.uptime.minute + " " + - sec.padStart(2, "0") + " " + client.translate.commands.uptime.second + " "; - - const clientColor = message.guild.members.me.displayHexColor; - const uptimeEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.uptime.info_title) - .setDescription("```" + duration + "```") - .setColor(clientColor); - - message.channel.send({ - "embeds": [uptimeEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -74,4 +48,4 @@ module.exports.interaction.slash = { "embeds": [uptimeEmbed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/developer/version.js b/source/commands/developer/version.js index a86cd2e5..23b97264 100644 --- a/source/commands/developer/version.js +++ b/source/commands/developer/version.js @@ -2,34 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { version } = require('../../../package.json'); module.exports = { + "enable": true, "name": "version", "description": "Check the current bot version.", "category": "developer", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "version", - "aliases": ["v", "เวอร์ชั่น"], - async execute(client, message, args) { - const versionEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.version.working_in_version.replace("%s", version)) - .setColor("Green"); - - message.channel.send({ - "embeds": [versionEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -51,4 +37,4 @@ module.exports.interaction.slash = { "embeds": [versionEmbed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/bigEmoji.js b/source/commands/fun/bigEmoji.js index 10f669b3..a6002178 100644 --- a/source/commands/fun/bigEmoji.js +++ b/source/commands/fun/bigEmoji.js @@ -2,6 +2,7 @@ const { parseEmoji, PermissionsBitField } = require('discord.js'); const { parse } = require("twemoji-parser"); module.exports = { + "enable": true, "name": "bigEmoji", "description": "Enlarge the emoji.", "category": "fun", @@ -10,41 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.EmbedLinks ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "bigEmoji ", - "aliases": ["bigemoji", "enlarge", "ขยาย"], - async execute(client, message, args) { - const inputEmoji = args[0]; - - if (!inputEmoji) return message.reply(client.translate.commands.bigemoji.empty_value); - - const custom = parseEmoji(inputEmoji); - - if (custom.id) { - const baseURL = "https://cdn.discordapp.com/emojis/"; - const file = custom.id + "." + custom.animated ? "gif" : "png"; - const emojiURL = baseURL + file; - - return message.channel.send({ "files": [emojiURL] }); - } - - const parsed = parse(inputEmoji, { "assetType": "png" }); - - if (!parsed[0]) return message.reply(client.translate.commands.bigemoji.emoji_not_found); - - message.channel.send({ "files": [parsed[0].url] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -75,7 +49,7 @@ module.exports.interaction.slash = { const inputEmoji = interaction.options.get("emoji").value; const custom = parseEmoji(inputEmoji); - + if (custom.id) { const baseURL = "https://cdn.discordapp.com/emojis/"; const file = custom.id + "." + custom.animated ? "gif" : "png"; @@ -85,9 +59,9 @@ module.exports.interaction.slash = { } const parsed = parse(inputEmoji, { "assetType": "png" }); - - if (!parsed[0]) return await interaction.editReply(interaction.client.translate.commands.bigemoji.emoji_not_found); + + if (!parsed[0]) return await interaction.editReply(interaction.client.translate.commands.bigEmoji.emoji_not_found); await interaction.editReply({ "files": [parsed[0].url] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/dead.js b/source/commands/fun/dead.js index d4e95886..8f8305a7 100644 --- a/source/commands/fun/dead.js +++ b/source/commands/fun/dead.js @@ -1,35 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "dead", "description": "Fake message that says you commit suicide.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "dead", - "aliases": ["die", "dead", "ตาย", "เสียชีวิต"], - async execute(client, message, args) { - const authorUsername = message.author.username; - const deadEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.dead.suicide.replace("%s", authorUsername)) - .setColor("Default"); - - message.channel.send({ - "embeds": [deadEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -52,4 +37,4 @@ module.exports.interaction.slash = { "embeds": [deadEmbed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/eat.js b/source/commands/fun/eat.js index d524fad5..4b35e4f4 100644 --- a/source/commands/fun/eat.js +++ b/source/commands/fun/eat.js @@ -1,48 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "eat", "description": "Fake text saying who you are eating.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "eat ", - "aliases": ["e", "กิน"], - async execute(client, message, args) { - const inputName = args.join(" "); - - if (!inputName) return message.reply(client.translate.commands.eat.empty); - - const authorUsername = message.author.username; - const clientUsername = client.user.username; - const eatEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.eat.already_eaten.replace("%s1", authorUsername).replace("%s2", inputName)) - .setColor("Default"); - - if (inputName === clientUsername) { - return message.reply("...").then(() => { - setTimeout(() => { - message.reply(client.translate.commands.eat.do_not_eat_me); - }, 8000); - }); - } - - message.channel.send({ - "embeds": [eatEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -90,4 +62,4 @@ module.exports.interaction.slash = { "embeds": [eatEmbed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/invite.js b/source/commands/fun/invite.js index f5b2b9b6..9a633356 100644 --- a/source/commands/fun/invite.js +++ b/source/commands/fun/invite.js @@ -1,6 +1,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "invite", "description": "Create and receive invitation links to join the server.", "category": "fun", @@ -10,34 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.CreateInstantInvite ] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "invite", - "aliases": ["เชิญ"], - async execute(client, message, args) { - message.channel.createInvite().then((invite) => { - const guildIcon = message.guild.iconURL(); - const inviteEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.invite.membership_invitation_card) - .setDescription("||" + invite.url + "||") - .setColor("LightGrey") - .setFooter({ "text": client.translate.commands.invite.this_product_is_free, "iconURL": guildIcon }); - - message.channel.send({ - "embeds": [inviteEmbed] - }); - }); - } + "function": { + "command": {} + } } -module.exports.interaction = { - "enable": true -}; - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -64,4 +45,4 @@ module.exports.interaction.slash = { }); }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/kill.js b/source/commands/fun/kill.js index 44268bfa..ca717ba9 100644 --- a/source/commands/fun/kill.js +++ b/source/commands/fun/kill.js @@ -1,42 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "kill", "description": "Fake messages that say you will kill something.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "kill ", - "aliases": ["kia", "ฆ่า"], - async execute(client, message, args) { - const inputName = args.join(" "); - - if (!inputName) return message.reply(client.translate.commands.kill.empty); - - const authorUsername = message.author.username; - const clientUsername = client.user.username; - const killEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.kill.killed.replace("%s1", authorUsername).replace("%s2", inputName)) - .setColor("Default"); - - if (inputName === clientUsername) return message.reply(client.translate.commands.kill.do_not_kill_me); - - message.channel.send({ - "embeds": [killEmbed] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/fun/levelingBoard.js b/source/commands/fun/levelingBoard.js index 6c29b55c..1b1d9073 100644 --- a/source/commands/fun/levelingBoard.js +++ b/source/commands/fun/levelingBoard.js @@ -2,84 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { levelSystem } = require("../../utils/databaseUtils"); module.exports = { + "enable": true, "name": "levelingBoard", "description": "See the ranking of people with the most EXP and Level on the server.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "levelingBoard", - "aliases": ["คะแนนเลเวล", "เลเวลผู้นำ", "levelingboard", "lboard", "levelingb", "lb"], - async execute(client, message, args) { - const map = []; - const max = 10; - const snapshot = await levelSystem(client, message, "GET/ALL"); - - if (!snapshot) return message.channel.send(client.translate.commands.levelingBoard.no_info); - - for (const users in snapshot) { - const member = message.guild.members.cache.find(members => (members.id === users)); - - if (member) { - if (!member.user.bot) { - const leveling = snapshot[member.user.id].leveling; - - if (leveling) { - const exp = leveling.exp; - const level = leveling.level; - - map.push({ - "data": { - "exp": exp, - "level": level, - "avatar": member.user.displayAvatarURL() - }, - "name": member.user.username, - "value": client.translate.commands.levelingBoard.leveling_detail.replace("%s1", exp).replace("%s2", level) - }); - } - } - } - } - - map.sort((userA, userB) => userB.data.level - userA.data.level || userB.data.exp - userA.data.exp); - - const userAvatar = map[0].data.avatar; - - for (let i = 0; i < map.length; i++) { - if (!map[i]) return; - if (i === max) return; - - delete map[i].data; - map[i].name = (i + 1) + ". " + map[i].name; - } - - const clientColor = message.guild.members.me.displayHexColor; - const clientAvatar = client.user.avatarURL(); - const clientUsername = client.user.username; - const embed = new EmbedBuilder() - .setColor(clientColor) - .setTitle(client.translate.commands.levelingBoard.server_rank) - .setAuthor({ "name": clientUsername, "iconURL": clientAvatar }) - .setThumbnail(userAvatar) - .setDescription(client.translate.commands.levelingBoard.server_rank_description) - .addFields(map) - .setTimestamp() - .setFooter({ "text": client.translate.commands.levelingBoard.server_rank_tips, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/electric-light-bulb_1f4a1.png" }); - - message.channel.send({ "embeds": [embed] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -151,4 +87,4 @@ module.exports.interaction.slash = { await interaction.editReply({ "embeds": [embed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/meme.js b/source/commands/fun/meme.js index 8c2db630..e0f7e713 100644 --- a/source/commands/fun/meme.js +++ b/source/commands/fun/meme.js @@ -3,108 +3,20 @@ const { randomInt } = require("../../utils/miscUtils"); const fetch = require("node-fetch"); module.exports = { + "enable": true, "name": "meme", "description": "Randomly select the meme you want.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "meme [category]", - "aliases": ["มีม", "mm"], - async execute(client, message, args) { - const inputCategory = args[0]; - - const randomEmbed = async (choice) => { - const category = ["meme", "Memes_Of_The_Dank", "memes", "dankmemes"]; - const random = choice ? choice : category[randomInt(category.length)]; - - const response = await fetch("https://www.reddit.com/r/" + random + "/random/.json"); - - if (response.status !== 200) { - return new EmbedBuilder() - .setColor("Red") - .setDescription(client.translate.commands.meme.can_not_fetch); - } - - const data = await response.json(); - - if (!Array.isArray(data) || data.length === 0) { - return new EmbedBuilder() - .setColor("Red") - .setDescription(client.translate.commands.meme.meme_not_found.replace("%s", choice)); - } - - try { - const permalink = data[0].data.children[0].data.permalink; - const memeUrl = "https://reddit.com" + permalink; - const memeImage = data[0].data.children[0].data.url; - const memeTitle = data[0].data.children[0].data.title; - const memeUpvotes = data[0].data.children[0].data.ups; - const memeNumComments = data[0].data.children[0].data.num_comments; - const memeCreate = data[0].data.children[0].data.created; - - return new EmbedBuilder() - .setTitle(memeTitle) - .setURL(memeUrl) - .setImage(memeImage) - .setColor("Random") - .setFooter({ "text": "👍 %s1 | 💬 %s2".replace("%s1", memeUpvotes).replace("%s2", memeNumComments) }) - .setTimestamp(new Date(memeCreate) * 1000); - } catch (error) { - return new EmbedBuilder() - .setColor("Red") - .setDescription(client.translate.commands.meme.can_not_fetch); - } - }; - - const memeEmbed = await randomEmbed(inputCategory); - const buttonRow = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId("regenMemeButton") - .setStyle(ButtonStyle.Secondary) - .setEmoji("🔁") - ); - const msg = await message.reply({ - "embeds": [memeEmbed], - "components": [buttonRow], - }); - const collector = message.channel.createMessageCollector({ - filter: (reactor) => reactor.user.id !== message.author.id, - "time": 60, - "max": 3, - "dispose": true, - }); - - collector.on("collect", async (response) => { - if (response.customId !== "regenMemeButton") return; - await response.deferUpdate(); - - const randomMemeEmbed = await randomEmbed(inputCategory); - - await msg.edit({ - "embeds": [randomMemeEmbed], - "components": [buttonRow], - }); - }); - - collector.on("end", () => { - buttonRow.components.forEach((button) => button.setDisabled(true)); - - return msg.edit({ "components": [buttonRow] }); - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/fun/nekos.js b/source/commands/fun/nekos.js index b471aba2..7bcc7986 100644 --- a/source/commands/fun/nekos.js +++ b/source/commands/fun/nekos.js @@ -2,75 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const fetch = require('node-fetch'); module.exports = { + "enable": true, "name": "nekos", "description": "Random anime pictures as you want.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "nekos ", - "aliases": ["nekoslife", "neko", "สุ่มอนิเมะ"], - async execute(client, message, args) { - const inputType = args[0] ? args[0].toLowerCase() : ""; - - const api = "https://nekos.life/api/v2"; - const endpoints = { - "tickle": "/img/tickle", - "slap": "/img/slap", - "poke": "/img/poke", - "pat": "/img/pat", - "neko": "/img/neko", - "meow": "/img/meow", - "lizard": "/img/lizard", - "kiss": "/img/kiss", - "hug": "/img/hug", - "foxGirl": "/img/fox_girl", - "feed": "/img/feed", - "cuddle": "/img/cuddle", - "nekoGif": "/img/ngif", - "kemonomimi": "/img/kemonomimi", - "holo": "/img/holo", - "smug": "/img/smug", - "baka": "/img/baka", - "woof": "/img/woof", - "wallpaper": "/img/wallpaper", - "goose": "/img/goose", - "gecg": "/img/gecg", - "avatar": "/img/avatar", - "waifu": "/img/waifu" - }; - const type = Object.keys(endpoints).toLowerCase(); - - if (!inputType) return message.reply(client.translate.commands.nekos.type_you_want.replace("%s", type.join(", "))); - if (!type.includes(inputType)) return message.reply(client.translate.commands.nekos.type_not_exists.replace("%s", type.join(", "))); - - fetch(api + endpoints[inputType]) - .then(response => response.json()) - .then(data => { - const title = Object.keys(endpoints).find(key => endpoints[key] === endpoints[inputType]); - const authorUsername = message.author.username; - const authorAvatar = message.author.displayAvatarURL(); - const nekosEmbed = new EmbedBuilder() - .setTitle(title.charAt(0).toUpperCase() + title.slice(1)) - .setColor("Random") - .setImage(data.url) - .setTimestamp() - .setFooter({ "iconURL": authorAvatar, "text": client.translate.commands.nekos.request_by.replace("%s", authorUsername) }); - - message.channel.send({ "embeds": [nekosEmbed] }); - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -220,10 +165,6 @@ module.exports.interaction.slash = { "avatar": "/img/avatar", "waifu": "/img/waifu" }; - const type = Object.keys(endpoints).toLowerCase(); - - if (!inputType) return await interaction.editReply(interaction.client.translate.commands.nekos.type_you_want.replace("%s", type.join(", "))); - if (!type.includes(inputType)) return await interaction.editReply(interaction.client.translate.commands.nekos.type_not_exists.replace("%s", type.join(", "))); fetch(api + endpoints[inputType]) .then(response => response.json()) @@ -241,4 +182,4 @@ module.exports.interaction.slash = { await interaction.editReply({ "embeds": [nekosEmbed] }); }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/numbers.js b/source/commands/fun/numbers.js index 633150cf..c737fde6 100644 --- a/source/commands/fun/numbers.js +++ b/source/commands/fun/numbers.js @@ -1,41 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "numbers", "description": "Random number.", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "numbers ", - "aliases": ["randomnumbers", "randomnumber", "number", "สุ่มเลข"], - async execute(client, message, args) { - let inputMin = parseInt(args[0]); - let inputMax = parseInt(args[1]); - - if (inputMin > inputMax) { - const temp = inputMax; - inputMax = inputMin; - inputMin = temp; - } - - const result = Math.floor(Math.random() * (inputMax - inputMin + 1)) + inputMin; - - if (!result) return message.reply(client.translate.commands.numbers.empty); - - message.channel.send(client.translate.commands.numbers.result.replace("%s", result)); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -86,8 +65,6 @@ module.exports.interaction.slash = { const result = Math.floor(Math.random() * (inputMax - inputMin + 1)) + inputMin; - if (!result) return await interaction.editReply(interaction.client.translate.commands.numbers.empty); - await interaction.editReply(interaction.client.translate.commands.numbers.result.replace("%s", result)); } } \ No newline at end of file diff --git a/source/commands/fun/rip.js b/source/commands/fun/rip.js index 6dd4863c..4d1f00ea 100644 --- a/source/commands/fun/rip.js +++ b/source/commands/fun/rip.js @@ -1,6 +1,7 @@ const { AttachmentBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "rip", "description": "Send RIP images", "category": "fun", @@ -10,27 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.AttachFiles ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "rip", - "aliases": ["rip", "อาร์ไอพี", "ลาก๋อย"], - async execute(client, message, args) { - const rip = new AttachmentBuilder("https://i.imgur.com/w3duR07.png"); - - if (!rip) return message.reply(client.translate.commands.rip.no_image); - - message.channel.send({ "files": [rip] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -50,4 +38,4 @@ module.exports.interaction.slash = { await interaction.editReply({ "files": [rip] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/fun/tableFlip.js b/source/commands/fun/tableFlip.js index 79e71182..f13b6f6c 100644 --- a/source/commands/fun/tableFlip.js +++ b/source/commands/fun/tableFlip.js @@ -1,42 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "tableFlip", "description": "(\\\\°□°)\\\\ ┬─┬", "category": "fun", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "tableFlip", - "aliases": ["tableflip", "tf", "ฟิบโต๊ะ"], - async execute(client, message, args) { - const frames = [ - "(-°□°)- ┬─┬", - "(╯°□°)╯ ]", - "(╯°□°)╯ ︵ ┻━┻", - "(╯°□°)╯ [", - "(╯°□°)╯ ┬─┬" - ]; - - message.channel.send("(\\\\°□°)\\\\ ┬─┬").then((msg) => { - for (const frame of frames) { - setTimeout(() => { - msg.edit(frame); - }, 1000); - } - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -53,7 +31,7 @@ module.exports.interaction.slash = { "(╯°□°)╯ [", "(╯°□°)╯ ┬─┬" ]; - + await interaction.editReply("(\\\\°□°)\\\\ ┬─┬").then(() => { for (const frame of frames) { setTimeout(async () => { @@ -62,4 +40,4 @@ module.exports.interaction.slash = { } }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/games/together.js b/source/commands/games/together.js index 17b84be5..d945e786 100644 --- a/source/commands/games/together.js +++ b/source/commands/games/together.js @@ -1,7 +1,8 @@ -const { ChannelType, PermissionsBitField } = require("discord.js"); +const { PermissionsBitField } = require("discord.js"); const fetch = require("node-fetch"); module.exports = { + "enable": true, "name": "together", "description": "Run a specific emulator through the audio channel.", "category": "games", @@ -11,85 +12,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.UseEmbeddedActivities ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "together (channel: name, id)", - "aliases": ["tg"], - async execute(client, message, args) { - const inputName = args[0]; - const inputChannel = args.slice(1).join(" "); - - const token = client.config.token; - let voiceChannel = message.member.voice.channel; - const apps = { - "youtube": "880218394199220334", - "youtubedev": "880218832743055411", - "poker": "755827207812677713", - "betrayal": "773336526917861400", - "fishing": "814288819477020702", - "chess": "832012774040141894", - "chessdev": "832012586023256104", - "lettertile": "879863686565621790", - "wordsnack": "879863976006127627", - "doodlecrew": "878067389634314250", - "awkword": "879863881349087252", - "spellcast": "852509694341283871", - "checkers": "832013003968348200", - "puttparty": "763133495793942528", - "sketchheads": "902271654783242291", - "blazing8s": "832025144389533716", - "puttpartyqa": "945748195256979606", - "sketchyartist": "879864070101172255", - "land": "903769130790969345", - "meme": "950505761862189096", - "askaway": "976052223358406656", - "bobble": "947957217959759964" - }; - const list = Object.keys(apps); - - if (!inputName) return message.reply(client.translate.commands.together.empty.replace("%s", list)); - if (!list.includes(inputName.toLowerCase())) return message.reply(client.translate.commands.together.do_not_have.replace("%s1", inputName).replace("%s2", list.length).replace("%s3", list)); - if (!inputChannel) { - if (!voiceChannel) return message.reply(client.translate.commands.together.user_not_in_channel); - } else { - voiceChannel = message.guild.channels.cache.find(channels => (channels.id === inputChannel) || (channels.name === inputChannel)); - - if (voiceChannel.type === ChannelType.GuildText) return message.reply(client.translate.commands.together.not_in_text_channel); - if (!voiceChannel) return message.reply(client.translate.commands.together.voice_channel_not_found); - } - - fetch("https://discord.com/api/v10/channels/" + voiceChannel.id + "/invites", { - "method": "POST", - "body": JSON.stringify({ - "max_age": 86400, - "max_uses": 0, - "target_application_id": apps[inputName], - "target_type": 2, - "temporary": false, - "validate": null, - }), - "headers": { - "Authorization": "Bot " + token, - "Content-Type": "application/json", - } - }) - .then((res) => res.json()) - .then((invite) => { - if (!invite.code) return message.reply(client.translate.commands.together.can_not_open.replace("%s", inputName)); - - message.channel.send(client.translate.commands.together.join_via_this_link + invite.code); - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "description": module.exports.description, @@ -273,9 +203,10 @@ module.exports.interaction.slash = { }) .then((res) => res.json()) .then(async (invite) => { - if (!invite.code) return await interaction.editReply(interaction.client.translate.commands.together.can_not_open.replace("%s", inputName)); + if (invite.error || !invite.code) return await interaction.editReply(interaction.client.translate.commands.together.can_not_open.replace("%s", inputName)); + if (Number(invite.code) === 50013) return await interaction.editReply(interaction.client.translate.commands.together.do_not_have_permission); await interaction.editReply(interaction.client.translate.commands.together.join_via_this_link + invite.code); }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/information/anime.js b/source/commands/information/anime.js index db3735d2..1dd36d04 100644 --- a/source/commands/information/anime.js +++ b/source/commands/information/anime.js @@ -2,6 +2,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const fetch = require("node-fetch"); module.exports = { + "enable": true, "name": "anime", "description": "Search for anime or manga available on Kitsu.", "category": "information", @@ -10,126 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.EmbedLinks ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "anime ", - "aliases": ["an", "cartoon", "kitsu", "อนิเมะ", "มังงะ", "การ์ดตูน"], - async execute(client, message, args) { - const inputTitle = args.join(" "); - - const titles = (data) => { - const numTitle = []; - - for (let i = 0; i < data.length; i++) { - const japanTitle = data[i].attributes.titles.en_jp ? data[i].attributes.titles.en_jp : ""; - const englishTitle = data[i].attributes.titles.en ? " / " + data[i].attributes.titles.en : ""; - const title = japanTitle + englishTitle; - - numTitle.push("\n" + (i + 1) + ". " + title); - } - - return numTitle.join(" "); - } - const filter = (content) => { - if (!content.content) return; - if (content.author.id !== message.author.id) return; - return ["1", "2", "3", "4", "5"].includes(content.content); - } - - if (!inputTitle) return message.reply(client.translate.commands.anime.empty); - - const baseURL = "https://kitsu.io/api/edge"; - const anime = "/anime?page[limit]=5&filter[text]=" + inputTitle; - const manga = "/manga?page[limit]=5&filter[text]=" + inputTitle; - const response = await fetch( - baseURL + anime || manga, - { - "headers": { - "Accept": "application/vnd.api+json", - "Content-Type": "application/vnd.api+json" - } - } - ); - const json = await response.json(); - - if (!json) return message.channel.send(client.translate.commands.anime.data_not_found); - - const clientAvatarURL = client.user.avatarURL(); - const infoEmbed = new EmbedBuilder() - .setTitle("```" + inputTitle + "```") - .setDescription(client.translate.commands.anime.similar_stories) - .setColor(16083235) - .setFooter({ "text": client.translate.commands.anime.auto_cancel, "iconURL": clientAvatarURL }) - .setAuthor({ "name": "Kitsu", "url": "https://kitsu.io/", "iconURL": "https://kitsu.io/android-chrome-192x192-6b1404d91a423ea12340f41fc320c149.png" }) - .addFields([ - { - "name": client.translate.commands.anime.choose_now, - "value": titles(json.data) - } - ]); - const msg = await message.channel.send({ "embeds": [infoEmbed] }); - - const collection = await message.channel.awaitMessages({ - filter, - "max": 1, - "time": 60000, - "errors": ["time"] - }); - const returnMessage = collection.first(); - const index = parseInt(returnMessage.content) - 1; - - const attributes = json.data[index].attributes; - const trimmedSynopsis = attributes.synopsis.length >= 1015 ? attributes.synopsis.substring(0, 1015) + "..." : attributes.synopsis; - - infoEmbed.setColor(12601856) - .setFooter({ "text": client.translate.commands.anime.short_information, "iconURL": clientAvatarURL }) - .setFields( - [ - { - "name": client.translate.commands.anime.japan_name, - "value": attributes.titles.en_jp || client.translate.commands.anime.undefined - }, - { - "name": client.translate.commands.anime.english_name, - "value": attributes.titles.en || client.translate.commands.anime.undefined - }, - { - "name": client.translate.commands.anime.start_date, - "value": attributes.startDate, - "inline": true - }, - { - "name": client.translate.commands.anime.end_date, - "value": attributes.endDate || client.translate.commands.anime.in_progress, - "inline": true - }, - { - "name": client.translate.commands.anime.popularity_rank, - "value": attributes.popularityRank.toString(), - "inline": true - }, - { - "name": client.translate.commands.anime.link, - "value": "" - }, - { - "name": client.translate.commands.anime.synopsis, - "value": "```" + trimmedSynopsis + "```" - } - ] - ); - await msg.edit({ "embeds": [infoEmbed] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -178,8 +67,6 @@ module.exports.interaction.slash = { return ["1", "2", "3", "4", "5"].includes(content.content); } - if (!inputTitle) return await interaction.editReply(interaction.client.translate.commands.anime.empty); - const baseURL = "https://kitsu.io/api/edge"; const anime = "/anime?page[limit]=5&filter[text]=" + inputTitle; const manga = "/manga?page[limit]=5&filter[text]=" + inputTitle; diff --git a/source/commands/information/covid.js b/source/commands/information/covid.js index 8854605e..7eb228f3 100644 --- a/source/commands/information/covid.js +++ b/source/commands/information/covid.js @@ -2,6 +2,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const fetch = require("node-fetch"); module.exports = { + "enable": true, "name": "covid", "description": "Get covid statistics for a country", "category": "information", @@ -10,71 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.EmbedLinks ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "covid ", - "aliases": ["โควิด"], - async execute(client, message, args) { - const inputCountry = args[0]; - - if (!inputCountry) return message.reply(client.translate.commands.covid.what_country); - - const response = await fetch("https://disease.sh/v3/covid-19/countries/" + inputCountry) - - if (response.status === 404) return message.reply(client.translate.commands.covid.country_not_found); - if (!response.ok) return message.reply(client.translate.commands.covid.backend_issue); - - const data = await response.json(); - - const date = new Date(data.updated); - const day = date.getDate(); - const month = date.getMonth() + 1; - const year = date.getFullYear(); - const hours = date.getHours(); - const minutes = "0" + date.getMinutes(); - const formattedTime = day + "/" + month + "/" + year + " " + client.translate.commands.covid.when + " " + hours + ':' + minutes.slice(-2); - - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const covidEmbed = new EmbedBuilder() - .setTitle("🧫 Covid - %s".replace("%s", data.country)) - .setThumbnail(data.countryInfo.flag) - .setColor(clientColor) - .addFields( - [ - { "name": client.translate.commands.covid.cases_total, "value": data.cases.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.cases_today, "value": data.todayCases.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.deaths_total, "value": data.deaths.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.deaths_today, "value": data.todayDeaths.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.recovered, "value": data.recovered.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.active, "value": data.active.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.critical_stage, "value": data.critical.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.cases_per_one_million, "value": data.casesPerOneMillion.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.tests, "value": data.tests.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.tests_per_one_million, "value": data.testsPerOneMillion.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.population, "value": data.population.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.one_case_per_people, "value": data.oneCasePerPeople.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.one_death_per_people, "value": data.oneDeathPerPeople.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.one_test_per_people, "value": data.oneTestPerPeople.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.active_per_one_million, "value": data.activePerOneMillion.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.recovered_per_one_million, "value": data.recoveredPerOneMillion.toLocaleString(), "inline": true }, - { "name": client.translate.commands.covid.critical_per_one_million, "value": data.criticalPerOneMillion.toLocaleString(), "inline": true } - ] - ) - .setFooter({ "text": client.translate.commands.covid.updated_on.replace("%s", formattedTime) }); - - message.channel.send({ "embeds": [covidEmbed] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -150,4 +94,4 @@ module.exports.interaction.slash = { await interaction.editReply({ "embeds": [covidEmbed] }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/information/guild.js b/source/commands/information/guild.js index a28e6f11..a3a8e7c0 100644 --- a/source/commands/information/guild.js +++ b/source/commands/information/guild.js @@ -1,223 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "guild", "description": "Get information about the server.", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "guild (info)", - "aliases": ["guildinfo", "gi", "เกี่ยวกับเซิร์ฟเวอร์"], - async execute(client, message, args) { - const inputData = args[0]; - - const dateFormat = (data) => { - if (!data) return; - - const date = new Date(data); - const days = [ - client.translate.commands.guild.sunday, - client.translate.commands.guild.monday, - client.translate.commands.guild.tuesday, - client.translate.commands.guild.wednesday, - client.translate.commands.guild.thursday, - client.translate.commands.guild.friday, - client.translate.commands.guild.saturday - ]; - const months = [ - client.translate.commands.guild.january, - client.translate.commands.guild.february, - client.translate.commands.guild.march, - client.translate.commands.guild.april, - client.translate.commands.guild.may, - client.translate.commands.guild.june, - client.translate.commands.guild.july, - client.translate.commands.guild.august, - client.translate.commands.guild.september, - client.translate.commands.guild.october, - client.translate.commands.guild.november, - client.translate.commands.guild.december - ]; - - return client.translate.commands.guild.format_at - .replace("%s1", days[date.getDay()]) - .replace("%s2", date.getDate()) - .replace("%s3", months[date.getMonth()]) - .replace("%s4", date.getFullYear()) - .replace("%s5", date.getHours()) - .replace("%s6", date.getMinutes()); - } - - const afkChannelId = message.guild.afkChannelId || client.translate.commands.guild.unknown; - const afkTimeout = message.guild.afkTimeout.toString() || client.translate.commands.guild.unknown; - const applicationId = message.guild.applicationId || client.translate.commands.guild.do_not_have; - const approximateMemberCount = message.guild.approximateMemberCount || client.translate.commands.guild.unknown; - const approximatePresenceCount = message.guild.approximatePresenceCount || client.translate.commands.guild.unknown; - const available = message.guild.available ? client.translate.commands.guild.available : client.translate.commands.guild.unavailable; - const banner = message.guild.bannerURL() || client.translate.commands.guild.do_not_have; - const createdAt = dateFormat(message.guild.createAt) || client.translate.commands.guild.unknown; - const createdTimestamp = dateFormat(message.guild.createdTimestamp) || client.translate.commands.guild.unknown; - const defaultMessageNotification = message.guild.defaultMessageNotification || client.translate.commands.guild.unknown; - const description = message.guild.description || client.translate.commands.guild.do_not_have; - const discoverySplash = message.guild.discoverySplashURL() || client.translate.commands.guild.do_not_have; - const explicitContentFilter = message.guild.explicitContentFilter.toString() || client.translate.commands.guild.unknown; - const features = message.guild.features.join() || client.translate.commands.guild.do_not_have; - const icon = message.guild.iconURL() || client.translate.commands.guild.unknown; - const id = message.guild.id || client.translate.commands.guild.unknown; - const joinedAt = dateFormat(message.guild.joinedAt) || client.translate.commands.guild.unknown; - const joinTimestamp = dateFormat(message.guild.joinTimestamp) || client.translate.commands.guild.unknown; - const large = message.guild.large ? client.translate.commands.guild.yes : client.translate.commands.guild.no; - const maximumMembers = message.guild.maximumMembers.toString() || client.translate.commands.guild.unknown; - const maximumPresences = message.guild.maximumPresences || client.translate.commands.guild.unknown; - const memberCount = message.guild.memberCount.toString() || client.translate.commands.guild.unknown; - const mfaLevel = message.guild.mfaLevel || client.translate.commands.guild.unknown; - const name = message.guild.name || client.translate.commands.guild.unknown; - const nameAcronym = message.guild.nameAcronym || client.translate.commands.guild.do_not_have; - const nsfwLevel = message.guild.nsfwLevel || client.translate.commands.guild.unknown; - const ownerId = message.guild.ownerId || client.translate.commands.guild.unknown; - const partnered = message.guild.partnered ? client.translate.commands.guild.yes : client.translate.commands.guild.none; - const preferredLocale = message.guild.preferredLocale || client.translate.commands.guild.unknown; - const premiumSubscriptionCount = message.guild.premiumSubscriptionCount.toString() || client.translate.commands.guild.unknown; - const premiumTier = message.guild.premiumTier || client.translate.commands.guild.unknown; - const publicUpdatesChannelId = message.guild.publicUpdatesChannelId || client.translate.commands.guild.unknown; - const rulesChannelId = message.guild.rulesChannelId || client.translate.commands.guild.unknown; - const splash = message.guild.splashURL() || client.translate.commands.guild.do_not_have; - const systemChannelId = message.guild.systemChannelId || client.translate.commands.guild.unknown; - const vanityURLCode = message.guild.vanityURLCode || client.translate.commands.guild.do_not_have; - const vanityURLUses = message.guild.vanityURLUses || client.translate.commands.guild.unknown; - const verificationLevel = message.guild.verificationLevel || client.translate.commands.guild.unknown; - const verified = message.guild.verified ? client.translate.commands.guild.yes : client.translate.commands.guild.none; - const widgetChannelId = message.guild.widgetChannelId || client.translate.commands.guild.unknown; - const widgetEnabled = message.guild.widgetEnabled ? client.translate.commands.guild.on : client.translate.commands.guild.off; - - const clientUsername = client.user.username; - const clientAvatarURL = client.user.avatarURL(); - const guildIcon = message.guild.iconURL(); - const embed = new EmbedBuilder() - .setTitle(client.translate.commands.guild.server_info) - .setDescription(client.translate.commands.guild.server_info_description) - .setColor("BLUE") - .setTimestamp() - .setFooter({ "text": client.translate.commands.guild.info_date, "iconURL": guildIcon || "" }) - .setThumbnail(guildIcon || "") - .setAuthor({ "name": clientUsername, "iconURL": clientAvatarURL }); - - const info = [ - "afkChannelId", - "afkTimeout", - "applicationId", - "approximateMemberCount", - "approximatePresenceCount", - "available", - "banner", - "createdAt", - "createdTimestamp", - "defaultMessageNotification", - "description", - "discoverySplash", - "explicitContentFilter", - "features", - "icon", - "id", - "joinedAt", - "joinTimestamp", - "large", - "maximumMembers", - "maximumPresences", - "memberCount", - "mfaLevel", - "name", - "nameAcronym", - "nsfwLevel", - "ownerId", - "partnered", - "preferredLocale", - "premiumSubscriptionCount", - "premiumTier", - "publicUpdatesChannelId", - "rulesChannelId", - "splash", - "systemChannelId", - "vanityURLCode", - "vanityURLUses", - "verificationLevel", - "verified", - "widgetChannelId", - "widgetEnabled" - ]; - - const infoList = [ - { "name": client.translate.commands.guild.afk_channel_id, "value": afkChannelId, "inline": true }, - { "name": client.translate.commands.guild.afk_timeout, "value": afkTimeout, "inline": true }, - { "name": client.translate.commands.guild.application_id, "value": applicationId, "inline": true }, - { "name": client.translate.commands.guild.approximate_member_count, "value": approximateMemberCount, "inline": true }, - { "name": client.translate.commands.guild.approximate_presence_count, "value": approximatePresenceCount, "inline": true }, - { "name": client.translate.commands.guild.guild_available, "value": available, "inline": true }, - { "name": client.translate.commands.guild.banner, "value": banner, "inline": true }, - { "name": client.translate.commands.guild.create_at, "value": createdAt, "inline": true }, - { "name": client.translate.commands.guild.create_timestamp, "value": createdTimestamp, "inline": true }, - { "name": client.translate.commands.guild.default_message_notification, "value": defaultMessageNotification, "inline": true }, - { "name": client.translate.commands.guild.description, "value": description, "inline": true }, - { "name": client.translate.commands.guild.discovery_splash, "value": discoverySplash, "inline": true }, - { "name": client.translate.commands.guild.explicit_content_filter, "value": explicitContentFilter, "inline": true }, - { "name": client.translate.commands.guild.features, "value": features, "inline": true }, - { "name": client.translate.commands.guild.icon, "value": icon, "inline": true }, - { "name": client.translate.commands.guild.id, "value": id, "inline": true }, - { "name": client.translate.commands.guild.joined_at, "value": joinedAt, "inline": true }, - { "name": client.translate.commands.guild.join_timestamp, "value": joinTimestamp, "inline": true }, - { "name": client.translate.commands.guild.large, "value": large, "inline": true }, - { "name": client.translate.commands.guild.maximum_members, "value": maximumMembers, "inline": true }, - { "name": client.translate.commands.guild.maximum_presences, "value": maximumPresences, "inline": true }, - { "name": client.translate.commands.guild.member_count, "value": memberCount, "inline": true }, - { "name": client.translate.commands.guild.mfa_level, "value": mfaLevel, "inline": true }, - { "name": client.translate.commands.guild.name, "value": name, "inline": true }, - { "name": client.translate.commands.guild.name_acronym, "value": nameAcronym, "inline": true }, - { "name": client.translate.commands.guild.nsfw_level, "value": nsfwLevel, "inline": true }, - { "name": client.translate.commands.guild.owner_id, "value": ownerId, "inline": true }, - { "name": client.translate.commands.guild.partnered, "value": partnered, "inline": true }, - { "name": client.translate.commands.guild.preferred_locale, "value": preferredLocale, "inline": true }, - { "name": client.translate.commands.guild.premium_subscription_count, "value": premiumSubscriptionCount, "inline": true }, - { "name": client.translate.commands.guild.premium_tier, "value": premiumTier, "inline": true }, - { "name": client.translate.commands.guild.public_updates_channel_id, "value": publicUpdatesChannelId, "inline": true }, - { "name": client.translate.commands.guild.rules_channel_id, "value": rulesChannelId, "inline": true }, - { "name": client.translate.commands.guild.splash, "value": splash, "inline": true }, - { "name": client.translate.commands.guild.system_channel_id, "value": systemChannelId, "inline": true }, - { "name": client.translate.commands.guild.vanity_url_code, "value": vanityURLCode, "inline": true }, - { "name": client.translate.commands.guild.vanity_url_uses, "value": vanityURLUses, "inline": true }, - { "name": client.translate.commands.guild.verification_level, "value": verificationLevel, "inline": true }, - { "name": client.translate.commands.guild.verified, "value": verified, "inline": true }, - { "name": client.translate.commands.guild.widget_channel_id, "value": widgetChannelId, "inline": true }, - { "name": client.translate.commands.guild.widget_enabled, "value": widgetEnabled, "inline": true } - ]; - - if (inputData) { - if (info.includes(inputData)) { - for (let i = 0; i < info.length; i++) { - if (inputData === info[i]) { - embed.addFields(infoList[i]); - message.channel.send({ "embeds": [embed] }); - } - } - } else { - message.reply(client.translate.commands.guild.specific_use.replace("%s", info.join(", "))); - } - } else { - embed.addFields(Array.from(infoList).slice(0, 25)); - message.channel.send({ "embeds": [embed] }); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -442,4 +239,4 @@ module.exports.interaction.slash = { await interaction.editReply({ "embeds": [embed] }); } } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/information/leveling.js b/source/commands/information/leveling.js index 508bd495..e22e5a2e 100644 --- a/source/commands/information/leveling.js +++ b/source/commands/information/leveling.js @@ -2,75 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { levelSystem } = require("../../utils/databaseUtils"); module.exports = { + "enable": true, "name": "leveling", "description": "See information about your level.", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "leveling (member: id, username, tag)", - "aliases": ["level", "lv", "เลเวล", "เวล"], - async execute(client, message, args) { - const inputMember = args.join(" "); - - let authorAvatar = message.author.displayAvatarURL(); - let authorFetch = await message.author.fetch(); - let authorID = message.author.id; - let memberBot = false; - - if (inputMember) { - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.leveling.can_not_find_user); - - authorAvatar = member.user.avatarURL(); - authorFetch = await member.user.fetch(); - authorID = member.user.id; - memberBot = member.user.bot; - } - if (memberBot) return message.reply(client.translate.commands.leveling.bot_do_not_have_level); - - const data = await levelSystem(client, message, "GET", authorID); - - if (!data) return message.reply(client.translate.commands.leveling.user_no_data); - - const exp = data.exp; - const level = data.level; - const nextEXP = data.nextEXP; - - const levelingEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.leveling.your_experience) - .setColor(authorFetch.accentColor) - .setThumbnail(authorAvatar) - .setTimestamp() - .addFields( - [ - { - "name": client.translate.commands.leveling.level, - "value": "```" + level + "```" - }, - { - "name": client.translate.commands.leveling.experience, - "value": "```" + exp + "/" + nextEXP + "```" - } - ] - ); - - message.channel.send({ - "embeds": [levelingEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/information/mcserver.js b/source/commands/information/mcserver.js index 24e3cbdd..df66da26 100644 --- a/source/commands/information/mcserver.js +++ b/source/commands/information/mcserver.js @@ -2,122 +2,20 @@ const { EmbedBuilder, AttachmentBuilder, PermissionsBitField } = require("discor const { statusBedrock, status } = require("minecraft-server-util"); module.exports = { + "enable": true, "name": "mcServer", "description": "Explore Minecraft server information", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "mcServer (port)", - "aliases": ["mcserver", "mcs", "minecraftserver", "มายคราฟ", "เซิร์ฟมายคราฟ", "mc"], - async execute(client, message, args) { - const inputPlatform = args[0]; - const inputIP = args[1]; - const inputPort = args[2]; - - const platform = ["pe", "be", "je", "pocket", "bedrock", "java", "pocket edition", "bedrock edition", "java edition"]; - const clientUsername = client.user.username; - const clientAvatar = client.user.displayAvatarURL(); - const serverInfo = new EmbedBuilder() - .setColor("#7ED321") - .setAuthor({ "name": clientUsername, "iconURL": clientAvatar }) - .setTitle(client.translate.commands.mcServer.server_available) - .setDescription(client.translate.commands.mcServer.server_detail) - .setTimestamp() - .setFooter({ "text": client.translate.commands.mcServer.last_check, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/clock-face-three-oclock_1f552.png" }); - const serverError = new EmbedBuilder() - .setColor("#D0021B") - .setAuthor({ "name": clientUsername, "iconURL": clientAvatar }) - .setDescription(client.translate.commands.mcServer.server_unavailable) - .setTimestamp() - .setFooter({ "text": client.translate.commands.mcServer.last_check, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/clock-face-three-oclock_1f552.png" }); - - if (!inputPlatform) return message.reply(client.translate.commands.mcServer.platform_required); - if (!platform.includes(inputPlatform.toLowerCase())) { - return message.reply(client.translate.commands.mcServer.no_platform.replace("%s", platform.join(", "))); - } - if (!inputIP) return message.reply(client.translate.commands.mcServer.ip_address_required); - if (inputPort && typeof inputPort === "number") return message.reply(client.translate.commands.mcServer.port_is_not_numeric); - if (inputPort && inputPort.toString().length !== 5) return message.reply(client.translate.commands.mcServer.five_letter_port); - - switch (inputPlatform.toLowerCase()) { - case "pe": - case "be": - case "pocket": - case "bedrock": - case "pocket edition": - case "bedrock edition": - statusBedrock(inputIP, inputPort ? parseInt(inputPort) : 19132).then((beRes) => { - const beEdition = beRes.edition; - const beMotd = beRes.motd.clean; - const beVersion = beRes.version.name ? beRes.version.name : client.translate.commands.mcServer.do_not_have; - const beMaxPlayers = beRes.players.max.toString(); - const beOnlinePlayers = beRes.players.online ? beRes.players.online.toString() : client.translate.commands.mcServer.do_not_have; - const beMode = beRes.gameMode ? beRes.gameMode.toString() : client.translate.commands.mcServer.do_not_have; - const beHost = beRes.srvRecord.host; - const bePort = beRes.srvRecord.port.toString(); - - serverInfo.addFields( - { "name": client.translate.commands.mcServer.edition, "value": beEdition, "inline": true }, - { "name": client.translate.commands.mcServer.address, "value": beHost, "inline": true }, - { "name": client.translate.commands.mcServer.port, "value": bePort, "inline": true }, - { "name": client.translate.commands.mcServer.motd, "value": beMotd, "inline": true }, - { "name": client.translate.commands.mcServer.version, "value": beVersion, "inline": true }, - { "name": client.translate.commands.mcServer.maximum_player_count, "value": beMaxPlayers, "inline": true }, - { "name": client.translate.commands.mcServer.player_in_server, "value": beOnlinePlayers, "inline": true }, - { "name": client.translate.commands.mcServer.mode, "value": beMode, "inline": true } - ); - - message.channel.send({ "embeds": [serverInfo] }); - }).catch(() => { - message.channel.send({ "embeds": [serverError] }); - }); - break; - case "je": - case "java": - case "java edition": - status(inputIP, inputPort ? parseInt(inputPort) : 25565).then((jeRes) => { - const jeVersion = jeRes.version.name ? jeRes.version.name : client.translate.commands.mcServer.do_not_have; - const jeOnlinePlayers = jeRes.players.online ? jeRes.players.online.toString() : client.translate.commands.mcServer.do_not_have; - const jeMaxPlayers = jeRes.players.max.toString(); - const jeMotd = jeRes.motd.clean; - - const jeFavicon = jeRes.favicon.split(",").slice(1).join(","); - const imageStream = Buffer.from(jeFavicon, "base64"); - const attachment = new AttachmentBuilder(imageStream, { "name": "favicon.png" }); - - const jeHost = jeRes.srvRecord.host; - const jePort = jeRes.srvRecord.port.toString(); - - serverInfo.setThumbnail("attachment://favicon.png") - .addFields( - { "name": client.translate.commands.mcServer.edition, "value": "MCJE", "inline": true }, - { "name": client.translate.commands.mcServer.address, "value": jeHost, "inline": true }, - { "name": client.translate.commands.mcServer.port, "value": jePort, "inline": true }, - { "name": client.translate.commands.mcServer.version, "value": jeVersion, "inline": true }, - { "name": client.translate.commands.mcServer.player_in_server, "value": jeOnlinePlayers, "inline": true }, - { "name": client.translate.commands.mcServer.maximum_player_count, "value": jeMaxPlayers, "inline": true }, - { "name": client.translate.commands.mcServer.motd, "value": jeMotd, "inline": true } - ); - - message.channel.send({ "embeds": [serverInfo], "files": [attachment] }); - }).catch(() => { - message.channel.send({ "embeds": [serverError] }); - }); - break; - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/information/paste.js b/source/commands/information/paste.js index 427119aa..8a152aaf 100644 --- a/source/commands/information/paste.js +++ b/source/commands/information/paste.js @@ -3,59 +3,20 @@ const { create } = require("sourcebin"); const { catchError } = require("../../utils/consoleUtils"); module.exports = { + "enable": true, "name": "paste", "description": "Paste the text in sourceb.in.", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "paste <content>", - "aliases": ["วาง"], - async execute(client, message, args) { - const inputTitle = args.shift(); - const inputContent = args.join(" "); - - if (!inputTitle) return message.reply(client.translate.commands.paste.title_empty); - if (!inputContent) return message.reply(client.translate.commands.paste.content_empty); - - let response; - - try { - response = await create( - [ - { - "name": " ", - "content": inputContent, - "language": "text", - }, - ], - { - "title": inputTitle, - "description": " ", - } - ); - } catch (error) { - return catchError(client, message, module.exports.help.name, error); - } - - if (!response) return message.reply(client.translate.commands.paste.backend_not_response); - - const url = response.url; - const raw = "https://cdn.sourceb.in/bins/" + response.key + "/0"; - - message.channel.send(("**Sourcebin**\n🔸 " + client.translate.commands.paste.file + ": <%s1>\n🔹 " + client.translate.commands.paste.raw + ": <%s2>").replace("%s1", url).replace("%s2", raw)); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/information/status.js b/source/commands/information/status.js index 2f7b0736..f128a23a 100644 --- a/source/commands/information/status.js +++ b/source/commands/information/status.js @@ -1,77 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "status", "description": "Check the status of all members within the server", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "status <type: online, offline, idle, dnd>", - "aliases": ["สถานะ"], - async execute(client, message, args) { - const inputType = args.join(" "); - - const guildIcon = message.guild.iconURL(); - const statusEmbed = new EmbedBuilder() - .setTimestamp() - .setFooter({ "text": client.translate.commands.status.data_by_server, "iconURL": guildIcon }); - - if (!inputType) return message.reply(client.translate.commands.status.empty); - if (!["online", "offline", "idle", "dnd"].includes(inputType)) { - return message.reply(client.translate.commands.status.no_status); - } - - switch (inputType) { - case "online": - const onlineCount = message.guild.members.cache.filter(members => members.presence ? members.presence.status === "online" : null).size; - - statusEmbed.setDescription(client.translate.commands.status.online_status.replace("%s", onlineCount)) - .setColor("Green"); - message.channel.send({ - "embeds": [statusEmbed] - }); - break; - case "offline": - const offlineCount = message.guild.members.cache.filter(members => members.presence ? members.presence.status === "offline" : "offline").size; - - statusEmbed.setDescription(client.translate.commands.status.offline_status.replace("%s", offlineCount)) - .setColor("Grey"); - message.channel.send({ - "embeds": [statusEmbed] - }); - break; - case "idle": - const idleCount = message.guild.members.cache.filter(members => members.presence ? members.presence.status === "idle" : null).size; - - statusEmbed.setDescription(client.translate.commands.status.idle_status.replace("%s", idleCount)) - .setColor("Yellow"); - message.channel.send({ - "embeds": [statusEmbed] - }); - break; - case "dnd": - const dndCount = message.guild.members.cache.filter(members => members.presence ? members.presence.status === "dnd" : null).size; - - statusEmbed.setDescription(client.translate.commands.status.dnd_status.replace("%s", dndCount)) - .setColor("Red"); - message.channel.send({ - "embeds": [statusEmbed] - }); - break; - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/information/translate.js b/source/commands/information/translate.js index 467c0324..8b196ad3 100644 --- a/source/commands/information/translate.js +++ b/source/commands/information/translate.js @@ -3,55 +3,21 @@ const { supportTranslate } = require("../../utils/miscUtils"); const { translate } = require("@vitalets/google-translate-api"); module.exports = { + "enable": true, "name": "translate", "description": "Translate text", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "translate <to> <message>", - "aliases": ["แปล", "tr"], - async execute(client, message, args) { - const inputTo = args[0]; - const inputMessage = args.slice(1).join(" "); - - if (!inputTo) return message.reply(client.translate.commands.translate.code_empty.replace("%s", Object.keys(supportTranslate).join(", "))); - if (inputTo.length < 2) return message.reply(client.translate.commands.translate.should_not_less_than_two); - if (!supportTranslate[inputTo]) return message.reply(client.translate.commands.translate.translate_support.replace("%s", Object.keys(supportTranslate).join(", "))); - if (!inputMessage) return message.reply(client.translate.commands.translate.message_empty); - - const response = await translate(inputMessage, { "to": inputTo }) - - if (!response) return message.reply(client.translate.commands.translate.can_not_translate); - - const resOutput = response.text; - const resInputCode = response.raw.src.toUpperCase(); - const resOutputCode = inputTo.toUpperCase(); - - const authorFetch = await message.author.fetch(); - const authorColor = authorFetch.accentColor; - const authorUsername = message.author.username; - const authorAvatar = message.author.displayAvatarURL() - const translateEmbed = new EmbedBuilder() - .setColor(authorColor) - .setTimestamp() - .setDescription("```" + resOutput + "```") - .setAuthor({ "iconURL": authorAvatar, "name": authorUsername + " " + client.translate.commands.translate.says }) - .setFooter({ "text": "[" + resInputCode + "] -> [" + resOutputCode + "]" }); - - message.channel.send({ "embeds": [translateEmbed] }); + "function": { + "command": {}, + "context": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -120,7 +86,7 @@ module.exports.interaction.slash = { } } -module.exports.interaction.context = { +module.exports.function.context = { "data": { "type": ApplicationCommandType.Message, "name": "contextTranslate", diff --git a/source/commands/information/user.js b/source/commands/information/user.js index 5e29ed51..67f5d14e 100644 --- a/source/commands/information/user.js +++ b/source/commands/information/user.js @@ -2,269 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { getDatabase, ref, child, set } = require("firebase/database"); module.exports = { + "enable": true, "name": "user", "description": "Get your user information", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "user (info) (member)", - "aliases": ["member", "members", "ผู้ใช้", "สมาชิก"], - async execute(client, message, args) { - const inputInfo = args[0]; - const inputMember = args[1]; - - const dateFormat = (data) => { - if (!data) return; - - const date = new Date(data); - const days = [ - client.translate.commands.guild.sunday, - client.translate.commands.guild.monday, - client.translate.commands.guild.tuesday, - client.translate.commands.guild.wednesday, - client.translate.commands.guild.thursday, - client.translate.commands.guild.friday, - client.translate.commands.guild.saturday - ]; - const months = [ - client.translate.commands.guild.january, - client.translate.commands.guild.february, - client.translate.commands.guild.march, - client.translate.commands.guild.april, - client.translate.commands.guild.may, - client.translate.commands.guild.june, - client.translate.commands.guild.july, - client.translate.commands.guild.august, - client.translate.commands.guild.september, - client.translate.commands.guild.october, - client.translate.commands.guild.november, - client.translate.commands.guild.december - ]; - - return client.translate.commands.guild.format_at - .replace("%s1", days[date.getDay()]) - .replace("%s2", date.getDate()) - .replace("%s3", months[date.getMonth()]) - .replace("%s4", date.getFullYear()) - .replace("%s5", date.getHours()) - .replace("%s6", date.getMinutes()); - }; - - let avatar = message.author.avatarURL() || client.translate.commands.user.unknown; - let bot = message.author.bot ? client.translate.commands.user.yes : client.translate.commands.user.none; - let createdAt = message.author.createdAt.toString() || client.translate.commands.user.unknown; - let createdTimestamp = dateFormat(message.author.createdTimestamp) || client.translate.commands.user.unknown; - let defaultAvatarURL = message.author.defaultAvatarURL || client.translate.commands.user.unknown; - let discriminator = message.author.discriminator || client.translate.commands.user.unknown; - let id = message.author.id || client.translate.commands.user.unknown; - let partial = message.author.partial ? client.translate.commands.user.yes : client.translate.commands.user.none; - let system = message.author.system ? client.translate.commands.user.yes : client.translate.commands.user.none; - let tag = message.author.tag || client.translate.commands.user.unknown; - let username = message.author.username || client.translate.commands.user.unknown; - - const usersSnapshot = client.api.apps.discord.guilds[message.guild.id].data.users - const usersRef = child(child(ref(getDatabase(), "Shioru/apps/discord/guilds"), message.guild.id), "data/users"); - const clientUsername = client.user.username; - const clientAvatarURL = client.user.avatarURL(); - const embed = new EmbedBuilder() - .setTitle(client.translate.commands.user.user_info) - .setDescription(client.translate.commands.user.user_info_description) - .setColor("BLUE") - .setTimestamp() - .setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar) - .setAuthor({ "name": clientUsername, "iconURL": clientAvatarURL }); - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (member) { - avatar = member.user.avatarURL() || client.translate.commands.user.unknown; - bot = member.user.bot ? client.translate.commands.user.yes : client.translate.commands.user.none; - createdAt = member.user.createdAt.toString() || client.translate.commands.user.unknown; - createdTimestamp = dateFormat(member.user.createdTimestamp) || client.translate.commands.user.unknown; - defaultAvatarURL = member.user.defaultAvatarURL || client.translate.commands.user.unknown; - discriminator = member.user.discriminator || client.translate.commands.user.unknown; - id = member.user.id || client.translate.commands.user.unknown; - partial = member.user.partial ? client.translate.commands.user.yes : client.translate.commands.user.none; - system = member.user.system ? client.translate.commands.user.yes : client.translate.commands.user.none; - tag = member.user.tag || client.translate.commands.user.unknown; - username = member.user.username || client.translate.commands.user.unknown; - } - - const info = [ - "avatarURL", - "bot", - "createAt", - "createdTimestamp", - "defaultAvatarURL", - "discriminator", - "id", - "partial", - "system", - "tag", - "username" - ]; - const infoList = [ - { "name": client.translate.commands.user.avatar, "value": avatar, "inline": true }, - { "name": client.translate.commands.user.bot, "value": bot, "inline": true }, - { "name": client.translate.commands.user.created_at, "value": createdAt, "inline": true }, - { "name": client.translate.commands.user.created_timestamp, "value": createdTimestamp, "inline": true }, - { "name": client.translate.commands.user.default_avatar_url, "value": defaultAvatarURL, "inline": true }, - { "name": client.translate.commands.user.discriminator, "value": discriminator, "inline": true }, - { "name": client.translate.commands.user.id, "value": id, "inline": true }, - { "name": client.translate.commands.user.partial, "value": partial, "inline": true }, - { "name": client.translate.commands.user.system, "value": system, "inline": true }, - { "name": client.translate.commands.user.tag, "value": tag, "inline": true }, - { "name": client.translate.commands.user.username, "value": username, "inline": true } - ]; - - if (inputInfo) { - if (inputMember) { - if (member) { - if (bot) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar); - - if (info.includes(inputInfo)) { - for (let i = 0; i < info.length; i++) { - if (inputInfo === info[i]) { - embed.addFields(infoList[i]); - message.channel.send({ "embeds": [embed] }); - } - } - } else { - message.reply(client.translate.commands.user.specific_use.replace("%s", info.join(", "))); - } - } else { - const snapshot = usersSnapshot[id].access; - - if (snapshot) { - if (snapshot.info) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar); - - if (info.includes(inputInfo)) { - for (let i = 0; i < info.length; i++) { - if (inputInfo === info[i]) { - embed.addFields(infoList[i]); - message.channel.send({ "embeds": [embed] }); - } - } - } else { - message.reply(client.translate.commands.user.specific_use.replace("%s", info.join(", "))); - } - } else { - message.reply(client.translate.commands.user.info.not_allowed); - } - } else { - set(child(child(usersRef, id), "access"), { - "avatar": false, - "info": false, - "uid": false - }).then(() => { - module.exports.run(client, message, args); - }); - } - } - } else { - message.reply(client.translate.commands.user.can_not_find_user.replace("%s", client.config.owner)); - } - } else { - if (member) { - if (bot) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar) - .addFields(Array.from(infoList)); - - message.channel.send({ "embeds": [embed] }); - } else { - const snapshot = usersSnapshot[id].access; - - if (snapshot) { - if (snapshot.info) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar) - .addFields(Array.from(infoList)); - - message.channel.send({ "embeds": [embed] }); - } else { - message.reply(client.translate.commands.user.info.not_allowed); - } - } else { - set(child(child(usersRef, id), "access"), { - "avatar": false, - "info": false, - "uid": false - }).then(() => { - module.exports.run(client, message, args); - }); - } - } - } else { - if (info.includes(inputInfo)) { - for (let i = 0; i < info.length; i++) { - if (inputInfo === info[i]) { - embed.addFields(infoList[i]); - message.channel.send({ "embeds": [embed] }); - } - } - } else { - message.reply(client.translate.commands.user.specific_use.replace("%s", info.join(", "))); - } - } - } - } else { - if (inputMember) { - if (member) { - if (bot) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar) - .addFields(Array.from(infoList)); - - message.channel.send({ "embeds": [embed] }); - } else { - const snapshot = usersSnapshot[id].access; - - if (snapshot) { - if (snapshot.info) { - embed.setFooter({ "text": client.translate.commands.user.info_date, "iconURL": avatar }) - .setThumbnail(avatar) - .addFields(Array.from(infoList)); - - message.channel.send({ "embeds": [embed] }); - } else { - message.reply(client.translate.commands.user.info.not_allowed); - } - } else { - set(child(child(usersRef, id), "access"), { - "avatar": false, - "info": false, - "uid": false - }).then(() => { - module.exports.run(client, message, args); - }); - } - } - } else { - message.reply(client.translate.commands.user.can_not_find_user.replace("%s", client.config.owner)); - } - } else { - embed.addFields(Array.from(infoList)); - message.channel.send({ "embeds": [embed] }); - } - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/information/weather.js b/source/commands/information/weather.js index 2f0a7dbf..1a31681a 100644 --- a/source/commands/information/weather.js +++ b/source/commands/information/weather.js @@ -3,144 +3,20 @@ const { catchError } = require("../../utils/consoleUtils"); const { find } = require("weather-js"); module.exports = { + "enable": true, "name": "weather", "description": "See today's weather in each area.", "category": "information", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "weather <area>", - "aliases": ["สภาพอากาศ"], - async execute(client, message, args) { - const inputArea = args.join(" "); - - if (!inputArea) return message.reply(client.translate.commands.weather.empty); - - find({ - "search": inputArea, - "degreeType": "C" - }, (error, result) => { - if (error) return catchError(client, message, module.exports.name, error); - if (!result) return message.channel.send(client.translate.commands.weather.no_result_found); - - const city = result[0]; - const current = city.current; - const location = city.location; - - switch (current.skytext) { - case "Clear": - current.skytext = client.translate.commands.weather.clear_weather; - break; - case "Light Rain": - current.skytext = client.translate.commands.weather.light_rain; - break; - case "Rain Showers": - current.skytext = client.translate.commands.weather.rain_showers; - break; - case "Mostly Cloudy": - current.skytext = client.translate.commands.weather.mostly_cloudy; - break; - case "Partly Sunny": - current.skytext = client.translate.commands.weather.partly_sunny; - break; - case "Partly Cloudy": - current.skytext = client.translate.commands.weather.partly_cloudy; - break; - case "Sunny": - current.skytext = client.translate.commands.weather.sunny; - break; - case "Rain": - current.skytext = client.translate.commands.weather.rain; - break; - case "Cloudy": - current.skytext = client.translate.commands.weather.cloudy; - break; - case "Mostly Sunny": - current.skytext = client.translate.commands.weather.mostly_sunny; - break; - case "Mostly Clear": - current.skytext = client.translate.commands.weather.mostly_clear; - break; - } - - const skyText = current.skytext; - const imageURL = current.imageUrl; - const timezone = location.timezone; - const degreeType = location.degreetype; - const temperature = current.temperature; - const feelsLike = current.feelslike; - const wind = current.winddisplay; - const humidity = current.humidity; - const day = current.day; - const date = current.date; - - const weatherEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.weather.weather) - .setDescription(client.translate.commands.weather.weather_at_the_moment.replace("%s1", city.location.name).replace("%s2", skyText)) - .setColor(44678) - .setFooter({ "text": client.translate.commands.weather.information_from_microsoft, "iconURL": "https://www.tonystam.com/en/img/Microsoft-portfolio.png" }) - .setThumbnail(imageURL) - .addFields( - [ - { - "name": client.translate.commands.weather.timezone, - "value": "UTC" + timezone, - "inline": true - }, - { - "name": client.translate.commands.weather.degree_type, - "value": degreeType, - "inline": true - }, - { - "name": client.translate.commands.weather.temperature, - "value": temperature, - "inline": true - }, - { - "name": client.translate.commands.weather.feels_like, - "value": feelsLike, - "inline": true - }, - { - "name": client.translate.commands.weather.wind, - "value": wind, - "inline": true - }, - { - "name": client.translate.commands.weather.humidity, - "value": humidity + "%", - "inline": true - }, - { - "name": client.translate.commands.weather.day, - "value": day, - "inline": true - }, - { - "name": client.translate.commands.weather.date, - "value": date, - "inline": true - } - ] - ); - - message.channel.send({ - "embeds": [weatherEmbed] - }); - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -170,8 +46,6 @@ module.exports.interaction.slash = { async execute(interaction) { const inputArea = interaction.options.get("area").value; - if (!inputArea) return await interaction.editReply(interaction.client.translate.commands.weather.empty); - find({ "search": inputArea, "degreeType": "C" @@ -286,4 +160,4 @@ module.exports.interaction.slash = { }); }); } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/source/commands/manager/ban.js b/source/commands/manager/ban.js index c042db97..250d74d2 100644 --- a/source/commands/manager/ban.js +++ b/source/commands/manager/ban.js @@ -1,6 +1,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "ban", "description": "Ban members within the server.", "category": "manager", @@ -10,70 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.BanMembers ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "ban <member: id, username, tag> (days) (reason)", - "aliases": ["b", "แบน"], - async execute(client, message, args) { - const inputMember = args[0]; - let inputDays = args[1]; - let inputReason = args.slice(2).join(" "); - - if (!inputMember) return message.reply(client.translate.commands.ban.empty); - - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.ban.user_not_found); - - const banned = await message.guild.bans.fetch(); - - if (banned.length > 0 && banned.map((user => user.user.id === member.user.id))) { - return message.reply(client.translate.commands.ban.member_has_banned) - } - - const memberPosition = member.roles.highest.position; - const authorPosition = message.member.roles.highest.position; - - if (authorPosition < memberPosition) return message.reply(client.translate.commands.ban.members_have_a_higher_role); - if (!member.bannable) return message.reply(client.translate.commands.ban.members_have_a_higher_role_than_me); - if (inputDays && 0 > inputDays > 7) return message.reply(client.translate.commands.ban.days_range); - if (!inputDays) inputDays = 0; - if (!inputReason) inputReason = ""; - - const ban = await message.guild.bans.create(member, { - "deleteMessageDays": inputDays, - "reason": inputReason - }); - const authorUsername = message.author.username; - const memberAvatar = ban.user.avatarURL(); - const memberUsername = ban.user.username; - - let embedTitle = client.translate.commands.ban.banned_for_time.replace("%s1", memberUsername).replace("%s2", inputDays); - - if (inputDays === 0) embedTitle = client.translate.commands.ban.permanently_banned.replace("%s", memberUsername); - if (!inputReason) inputReason = client.translate.commands.ban.no_reason; - - const banEmbed = new EmbedBuilder() - .setTitle(embedTitle) - .setDescription(client.translate.commands.ban.reason_for_ban.replace("%s1", authorUsername).replace("%s2", inputReason)) - .setColor("Orange") - .setTimestamp() - .setThumbnail(memberAvatar); - - message.channel.send({ - "embeds": [banEmbed] - }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/manager/deleteLeveling.js b/source/commands/manager/deleteLeveling.js index f27f2c07..f6ce811a 100644 --- a/source/commands/manager/deleteLeveling.js +++ b/source/commands/manager/deleteLeveling.js @@ -2,6 +2,7 @@ const { PermissionsBitField } = require("discord.js"); const { levelSystem } = require("../../utils/databaseUtils"); module.exports = { + "enable": true, "name": "deleteLevel", "description": "Removing EXP and Level of members", "category": "manager", @@ -11,37 +12,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ManageGuild ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "deleteLevel <member: id, username, tag>", - "aliases": ["dleveling", "dlevel", "delleveling", "dellevel", "deletelevel", "deleteleveling", "ลบระดับชั้น"], - async execute(client, message, args) { - const inputMember = args.join(" "); - - if (!inputMember) return message.reply(client.translate.commands.deleteLevel.empty); - - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.deleteLevel.can_not_find_user); - - const memberID = member.user.id; - const msg = await message.reply(client.translate.commands.deleteLevel.deleting); - const data = await levelSystem(client, message, "DELETE", memberID); - - if (data === "missing") return message.reply(client.translate.commands.deleteLevel.user_current_no_level); - if (data === "success") return msg.edit(client.translate.commands.deleteLevel.success); - if (data === "error") return msg.edit(client.translate.commands.deleteLevel.error); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/manager/kick.js b/source/commands/manager/kick.js index 15383f1a..265a4f0e 100644 --- a/source/commands/manager/kick.js +++ b/source/commands/manager/kick.js @@ -1,6 +1,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "kick", "description": "Kick members from the server.", "category": "manager", @@ -10,57 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.KickMembers ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "kick <member: id, username, tag> (reason)", - "aliases": ["k", "เตะ"], - async execute(client, message, args) { - const inputMember = args[0]; - let inputReason = args.slice(1).join(" "); - - if (!inputMember) return message.reply(client.translate.commands.kick.empty); - - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.kick.can_not_find_user); - - const memberPosition = member.roles.highest.position; - const authorPosition = message.member.roles.highest.position; - - if (authorPosition < memberPosition) return message.reply(client.translate.commands.kick.members_have_a_higher_role); - if (!member.kickable) return message.reply(client.translate.commands.kick.members_have_a_higher_role_than_me); - if (!inputReason) inputReason = ""; - - const kicked = await member.kick({ - "reason": inputReason - }); - const authorUsername = message.author.username; - const memberAvatar = kicked.user.avatarURL(); - const memberUsername = kicked.user.username; - - if (!inputReason) inputReason = client.translate.commands.kick.no_reason; - - const kickEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.kick.kicked_out.replace("%s", memberUsername)) - .setDescription(client.translate.commands.kick.reason_for_kick.replace("%s1", authorUsername).replace("%s2", inputReason)) - .setColor("Orange") - .setTimestamp() - .setThumbnail(memberAvatar); - - message.channel.send({ - "embeds": [kickEmbed] - }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/manager/purge.js b/source/commands/manager/purge.js index 747d0a29..f894a195 100644 --- a/source/commands/manager/purge.js +++ b/source/commands/manager/purge.js @@ -2,6 +2,7 @@ const { PermissionsBitField } = require("discord.js"); const { catchError } = require("../../utils/consoleUtils"); module.exports = { + "enable": true, "name": "purge", "description": "Delete a lot of messages", "category": "manager", @@ -15,41 +16,14 @@ module.exports = { PermissionsBitField.Flags.ReadMessageHistory, PermissionsBitField.Flags.ManageMessages ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "purge <amount>", - "aliases": ["clear", "messagedelete", "ลบข้อความ"], - async execute(client, message, args) { - let messageCount = parseInt(args[0]); - - if (!messageCount) return message.reply(client.translate.commands.purge.purge_instructions); - if (messageCount > 100) return message.reply(client.translate.commands.purge.too_much); - if (messageCount <= 0) return message.reply(client.translate.commands.purge.too_little); - - message.channel.messages.fetch({ - "limit": 1 - }).then((previousMessages) => { - message.channel.messages.fetch({ - "limit": messageCount, - "before": previousMessages.first().id - }).then(async (messages) => { - await message.channel.bulkDelete(messages, true); - message.channel.send(client.translate.commands.purge.message_cleared.replace("%s", messages.size)); - }).catch((error) => { - catchError(client, message, module.exports.name, error); - }); - }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/manager/setEXP.js b/source/commands/manager/setEXP.js index 22c18f74..1e2bcd46 100644 --- a/source/commands/manager/setEXP.js +++ b/source/commands/manager/setEXP.js @@ -2,6 +2,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { levelSystem } = require("../../utils/databaseUtils"); module.exports = { + "enable": true, "name": "setEXP", "description": "Set the members' experience.", "category": "manager", @@ -11,68 +12,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ManageGuild ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "setEXP <member: id, username, tag> <amount>", - "aliases": ["setexp", "sexp", "ตั้งค่าEXP", "ตั้งค่าExp"], - async execute(client, message, args) { - const inputMember = args[0]; - const inputAmount = parseInt(args.slice(1).join(" ")); - - if (!inputMember) return message.reply(client.translate.commands.setEXP.empty); - if (!inputAmount) return message.reply(client.translate.commands.setEXP.amount_empty); - - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.setEXP.can_not_find_user); - - const memberAvatar = member.user.avatarURL(); - const memberUsername = member.user.username; - const memberID = member.user.id; - - const data = await levelSystem(client, message, "PUT", memberID, inputAmount); - - const exp = data.exp; - const level = data.level; - const notify = data.notify; - const status = data.status; - - if (status === "error") return message.reply(client.translate.commands.setEXP.error); - if (notify) { - const setEXPEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.setEXP.exp_was_changed.replace("%s", memberUsername)) - .setColor("Blue") - .setThumbnail(memberAvatar) - .setFooter({ "text": client.translate.commands.setEXP.set_by_staff, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/pencil_270f.png" }) - .addFields( - [ - { - "name": client.translate.commands.setEXP.level, - "value": "```" + level + "```" - }, - { - "name": client.translate.commands.setEXP.experience, - "value": "```" + exp + "```" - } - ] - ); - - await notify.send({ "embeds": [setEXPEmbed] }); - message.channel.send(client.translate.commands.setEXP.notification_complete); - } else { - message.channel.send(client.translate.commands.setEXP.success); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/manager/setLevel.js b/source/commands/manager/setLevel.js index 8a24592f..d0043e9d 100644 --- a/source/commands/manager/setLevel.js +++ b/source/commands/manager/setLevel.js @@ -2,6 +2,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { levelSystem } = require("../../utils/databaseUtils"); module.exports = { + "enable": true, "name": "setLevel", "description": "Set Level of Members", "category": "manager", @@ -11,68 +12,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ManageGuild ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "setLevel <member; id, username, tag> <amount>", - "aliases": ["slevel", "setlevel", "ตั้งค่าเลเวล"], - async execute(client, message, args) { - const inputMember = args[0]; - const inputAmount = parseInt(args.slice(1).join(" ")); - - if (!inputMember) return message.reply(client.translate.commands.setLevel.empty); - if (!inputAmount) return message.reply(client.translate.commands.setLevel.amount_empty); - - const member = message.guild.members.cache.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!member) return message.reply(client.translate.commands.setLevel.can_not_find_user); - - const memberAvatar = member.user.avatarURL(); - const memberUsername = member.user.username; - const memberID = member.user.id; - - const data = levelSystem(client, message, "PUT", memberID, inputAmount); - - const exp = data.exp; - const level = data.level; - const notify = data.notify; - const status = data.status; - - if (status === "error") return message.reply(client.translate.commands.setLevel.error); - if (notify) { - const setLevelEmbed = new EmbedBuilder() - .setDescription(client.translate.commands.setLevel.level_was_changed.replace("%s", memberUsername)) - .setColor("Blue") - .setThumbnail(memberAvatar) - .setFooter({ "text": client.translate.commands.setLevel.set_by_staff, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/pencil_270f.png" }) - .addFields( - [ - { - "name": client.translate.commands.setLevel.level, - "value": "```" + exp + "```" - }, - { - "name": client.translate.commands.setLevel.experience, - "value": "```" + level + "```" - } - ] - ); - - await notify.send({ "embeds": [setLevelEmbed] }); - message.channel.send(client.translate.commands.setLevel.notification_complete); - } else { - message.channel.send(client.translate.commands.setLevel.success); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/manager/unban.js b/source/commands/manager/unban.js index bd4a494f..9e3421b7 100644 --- a/source/commands/manager/unban.js +++ b/source/commands/manager/unban.js @@ -1,6 +1,7 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "unban", "description": "Stop banning members who are banned in the server.", "category": "manager", @@ -10,58 +11,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.BanMembers ] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "unban <member: id, username, tag> (reason)", - "aliases": ["unb", "ปลดแบน"], - async execute(client, message, args) { - const inputMember = args[0]; - let inputReason = args.slice(1).join(" "); - - if (!inputMember) return message.reply(client.translate.commands.unban.input_member_empty); - - const banned = await message.guild.bans.fetch(); - - if (banned.length <= 0) return message.reply(client.translate.commands.unban.no_one_gets_banned); - - const bannedUser = banned.find(members => (members.user.username === inputMember) || (members.user.id === inputMember) || (members.user.tag === inputMember)); - - if (!bannedUser) return message.reply(client.translate.commands.unban.this_user_not_banned); - if (!inputReason) inputReason = ""; - - message.guild.bans.remove(bannedUser.user, { - "reason": inputReason - }).then(() => { - const authorUsername = message.author.username; - const memberUsername = bannedUser.user.username; - const memberID = bannedUser.user.id; - const memberAvatar = bannedUser.user.avatar; - const memberAvatarURL = "https://cdn.discordapp.com/avatars/" + memberID + "/" + memberAvatar + ".png"; - - if (!inputReason) inputReason = client.translate.commands.unban.no_reason; - - const unbanEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.unban.user_has_been_unbanned.replace("%s", memberUsername)) - .setDescription(client.translate.commands.unban.reason_for_unban.replace("%s1", authorUsername).replace("%s2", inputReason)) - .setColor("Green") - .setTimestamp() - .setThumbnail(memberAvatarURL); - - message.channel.send({ - "embeds": [unbanEmbed] - }); - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/me/about.js b/source/commands/me/about.js index 55e7062d..dff18ce6 100644 --- a/source/commands/me/about.js +++ b/source/commands/me/about.js @@ -1,41 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "about", "description": "See information about bots.", "category": "me", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "about", - "aliases": ["information", "botinfo", "เกี่ยวกับ", "เกี่ยวกับบอท"], - async execute(client, message, args) { - const clientFetch = await client.user.fetch(); - const clientAvatar = client.user.avatarURL(); - const clientUsername = client.user.username; - const clientColor = clientFetch.accentColor; - const contentUpdate = client.config.update; - const aboutEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.about.my_profile) - .setDescription(client.translate.commands.about.my_profile_detail.replace("%s", clientUsername)) - .setColor(clientColor) - .setTimestamp(new Date(contentUpdate)) - .setAuthor({ "name": clientUsername, "iconURL": clientAvatar, "url": "https://shiorus.web.app/" }) - .setFooter({ "text": client.translate.commands.about.update_on, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/310/fountain-pen_1f58b-fe0f.png" }); - - message.channel.send({ "embeds": [aboutEmbed] }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/me/bug.js b/source/commands/me/bug.js index 2cf1ef50..482f69db 100644 --- a/source/commands/me/bug.js +++ b/source/commands/me/bug.js @@ -2,53 +2,20 @@ const { PermissionsBitField } = require("discord.js"); const { getDatabase, ref, push, update } = require("firebase/database"); module.exports = { + "enable": true, "name": "bug", "description": "Report error information about bots.", "category": "me", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "bug <message>", - "aliases": ["bugreport", "bugReport", "breport"], - async execute(client, message, args) { - const inputMessage = args.join(" "); - - const db = getDatabase(); - const dbRef = ref(db, "Shioru/data/bugs"); - - const authorUid = message.author.id; - const authorTag = message.author.tag; - const date = new Date(); - - if (!inputMessage) return message.reply(client.translate.commands.bug.message_required); - if (inputMessage.length < 5) return message.reply(client.translate.commands.bug.too_short_message); - - let msg = await message.channel.send(client.translate.commands.bug.sending); - update(push(dbRef), { - "message": inputMessage, - "user": authorTag, - "uid": authorUid, - "reportAt": date, - "status": { - "read": false, - "close": false, - "comment": false - } - }).then(() => { - msg.edit(client.translate.commands.bug.success); - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -80,7 +47,7 @@ module.exports.interaction.slash = { const inputMessage = interaction.options.get("message").value; const db = getDatabase(); - const dbRef = ref(db, "Shioru/data/bugs"); + const dbRef = ref(db, "projects/shioru/bugs"); const authorUid = interaction.user.id; const authorTag = interaction.user.tag; diff --git a/source/commands/me/credits.js b/source/commands/me/credits.js index 74154efc..46172ca6 100644 --- a/source/commands/me/credits.js +++ b/source/commands/me/credits.js @@ -1,51 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "credits", "description": "Credit of other creators.", "category": "me", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "credits", - "aliases": ["เครดิต", "creator"], - async execute(client, message, args) { - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const clientUsername = client.user.username; - const clientAvatar = client.user.displayAvatarURL(); - const contentUpdate = client.config.update; - const creditEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.credits.creator_credit) - .setDescription(client.translate.commands.credits.creator_credit_description) - .setColor(clientColor) - .setTimestamp(new Date(contentUpdate)) - .setFooter({ "text": client.translate.commands.credits.update_on, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/209/lower-left-ballpoint-pen_1f58a.png" }) - .setAuthor({ "name": clientUsername, "iconURL": clientAvatar, "url": "https://shiorus.web.app/" }) - .addFields( - [ - { - "name": "1. 夏月 まりな (NATSUKI MARINA)", - "value": client.translate.commands.credits.natsuki_marina_credit - } - ] - ); - - message.channel.send({ - "embeds": [creditEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/me/donate.js b/source/commands/me/donate.js index 37a67f16..fb4b86ad 100644 --- a/source/commands/me/donate.js +++ b/source/commands/me/donate.js @@ -1,6 +1,7 @@ const { ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField } = require('discord.js'); module.exports = { + "enable": true, "name": "donate", "description": "Donate to support bots and bot developers.", "category": "me", @@ -9,40 +10,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.EmbedLinks ] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "donate", - "aliases": ["support"], - async execute(client, message, args) { - const patreon = "https://www.patreon.com/maseshi"; - const bmc = "https://www.buymeacoffee.com/maseshi"; - const row = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setURL(patreon) - .setLabel('Patreon') - .setStyle(ButtonStyle.Link), - new ButtonBuilder() - .setURL(bmc) - .setLabel('Buy me a coffee') - .setStyle(ButtonStyle.Link) - ); - - message.channel.send({ - "content": client.translate.commands.donate.thank_you_in_advance_message, - "components": [row] - }); + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/me/help.js b/source/commands/me/help.js index d65219a5..c2dd7c2f 100644 --- a/source/commands/me/help.js +++ b/source/commands/me/help.js @@ -2,91 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { readdirSync } = require("node:fs"); module.exports = { + "enable": true, "name": "help", "description": "Get help with the use of bots.", "category": "me", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "help (command: name, aliases)", - "aliases": ["h", "ช่วยด้วย", "ช่วยเหลือ"], - async execute(client, message, args) { - let inputCommand = args[0]; - - const info = new EmbedBuilder() - .setColor("#E01055") - .setTitle(client.translate.commands.help.document_name) - .setAuthor({ "name": client.user.username, "iconURL": client.user.displayAvatarURL() }) - .setFooter({ "text": client.translate.commands.help.request_by + " " + message.author.username, "iconURL": message.author.displayAvatarURL() }) - .setTimestamp(); - - if (inputCommand) { - let commands; - - if (client.commands.has(inputCommand)) commands = client.commands.get(inputCommand); - if (client.aliases.has(inputCommand)) commands = client.commands.get(client.aliases.get(inputCommand)); - if (!commands) { - info.setTitle(client.translate.commands.help.command_incorrect) - .setDescription(client.translate.commands.help.command_incorrect_guide.replace("%s", client.config.prefix)) - - return message.reply({ "embeds": [info] }); - } - - inputCommand = commands; - - info.setTitle(client.translate.commands.help.command_detail + inputCommand.name.slice(0, 1).toUpperCase() + inputCommand.name.slice(1)) - .setDescription([ - "```" + client.translate.commands.help.command + (inputCommand.name.slice(0, 1).toUpperCase() + inputCommand.name.slice(1)), - client.translate.commands.help.description + (inputCommand.description || client.translate.commands.help.no_description), - client.translate.commands.help.how_to_use + client.config.prefix + (inputCommand.command.usage ? inputCommand.command.usage : client.translate.commands.help.unknown_how_to_use), - client.translate.commands.help.type + (inputCommand.category ? inputCommand.category : "General"), - client.translate.commands.help.aliases + (inputCommand.command.aliases ? inputCommand.command.aliases.join(", ") + "```" : client.translate.commands.help.do_not_have + "```"), - client.translate.commands.help.tip.replace("%s1", (client.config.prefix + inputCommand.name.slice(0, 1).toUpperCase() + inputCommand.name.slice(1))).replace("%s2", (client.config.prefix + inputCommand.command.aliases[0])) - ].join("\n")); - - message.channel.send({ "embeds": [info] }); - } else { - const categories = readdirSync("./source/commands/"); - - await info.setDescription([ - client.translate.commands.help.commands_description[0], - client.translate.commands.help.commands_description[1].replace("%s", client.config.prefix), - client.translate.commands.help.commands_description[2], - client.translate.commands.help.commands_description[3].replace("%s1", (client.config.prefix + module.exports.name)).replace("%s2", ("/" + module.exports.name)) - ].join("\n")); - - categories.forEach((category) => { - const dir = client.commands.filter(dirs => dirs.category.toLowerCase() === category.toLowerCase()); - const categorize = category.slice(0, 1).toUpperCase() + category.slice(1); - - if (!dir.size) return; - if (category === "owner" && message.author.id !== client.config.owner) return; - if (category === "owner") return info.addFields({ "name": "🔒 " + categorize + " - (" + dir.size + ")", "value": dir.map(dirs => "`" + dirs.name + "`").join(", ") }); - if (category === "developer") return info.addFields({ "name": "⌨ " + categorize + " - (" + dir.size + ")", "value": dir.map(dirs => "`" + dirs.name + "`").join(", ") }); - if (category === "settings") return info.addFields({ "name": "⚙️ " + categorize + " - (" + dir.size + ")", "value": dir.map(dirs => "`" + dirs.name + "`").join(", ") }); - - info.addFields( - { - "name": "🏷️ " + categorize + " - (" + dir.size + ")", - "value": dir.map(dirs => dirs.command.enable ? ("`" + dirs.name + "`") : ("||" + dirs.name + "||")).join(", ") - } - ); - }); - - message.channel.send({ "embeds": [info] }); - } - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -130,7 +59,7 @@ module.exports.interaction.slash = { if (interaction.client.aliases.has(inputCommand.value)) commands = interaction.client.commands.get(interaction.client.aliases.get(inputCommand.value)); if (!commands) { info.setTitle(interaction.client.translate.commands.help.command_incorrect) - .setDescription(interaction.client.translate.commands.help.command_incorrect_guide.replace("%s", interaction.client.config.prefix)) + .setDescription(interaction.client.translate.commands.help.command_incorrect_guide) return await interaction.editReply({ "embeds": [info] }); } @@ -141,10 +70,8 @@ module.exports.interaction.slash = { .setDescription([ "```" + interaction.client.translate.commands.help.command + (inputCommand.name.slice(0, 1).toUpperCase() + inputCommand.name.slice(1)), interaction.client.translate.commands.help.description + (inputCommand.description || interaction.client.translate.commands.help.no_description), - interaction.client.translate.commands.help.how_to_use + interaction.client.config.prefix + (inputCommand.command.usage ? inputCommand.command.usage : interaction.client.translate.commands.help.unknown_how_to_use), - interaction.client.translate.commands.help.type + (inputCommand.category ? inputCommand.category : "General"), - interaction.client.translate.commands.help.aliases + (inputCommand.command.aliases ? inputCommand.command.aliases.join(", ") + "```" : interaction.client.translate.commands.help.do_not_have + "```"), - interaction.client.translate.commands.help.tip.replace("%s1", (interaction.client.config.prefix + inputCommand.name.slice(0, 1).toUpperCase() + inputCommand.name.slice(1))).replace("%s2", (interaction.client.config.prefix + inputCommand.command.aliases[0])) + interaction.client.translate.commands.help.how_to_use + "/" + (inputCommand.command.usage ? inputCommand.command.usage : interaction.client.translate.commands.help.unknown_how_to_use), + interaction.client.translate.commands.help.type + (inputCommand.category ? inputCommand.category : "General") ].join("\n")); await interaction.editReply({ "embeds": [info] }); @@ -153,9 +80,9 @@ module.exports.interaction.slash = { await info.setDescription([ interaction.client.translate.commands.help.commands_description[0], - interaction.client.translate.commands.help.commands_description[1].replace("%s", interaction.client.config.prefix), + interaction.client.translate.commands.help.commands_description[1], interaction.client.translate.commands.help.commands_description[2], - interaction.client.translate.commands.help.commands_description[3].replace("%s1", (interaction.client.config.prefix + module.exports.name)).replace("%s2", ("/" + module.exports.name)) + interaction.client.translate.commands.help.commands_description[3] ].join("\n")); categories.forEach((category) => { diff --git a/source/commands/me/inviteMe.js b/source/commands/me/inviteMe.js index 2b0f3496..cf237cd3 100644 --- a/source/commands/me/inviteMe.js +++ b/source/commands/me/inviteMe.js @@ -1,45 +1,20 @@ const { OAuth2Scopes, PermissionsBitField, PermissionFlagsBits } = require("discord.js"); module.exports = { + "enable": true, "name": "inviteMe", "description": "Invite the bot to your server.", "category": "me", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "inviteMe", - "aliases": ["inviteme", "ime"], - async execute(client, message, args) { - try { - const link = client.generateInvite({ - "scopes": [ - OAuth2Scopes.ApplicationsCommands, - OAuth2Scopes.Bot - ], - "permissions": [ - PermissionFlagsBits.Administrator - ] - }); - - message.channel.send(link); - } catch(error) { - message.reply(client.translate.commands.inviteMe.can_not_create_invite_link); - console.group(); - console.error(error); - console.groupEnd(); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/me/say.js b/source/commands/me/say.js index dc271d0d..6c6c7181 100644 --- a/source/commands/me/say.js +++ b/source/commands/me/say.js @@ -1,53 +1,21 @@ -const { ChannelType, PermissionsBitField } = require("discord.js") +const { PermissionsBitField } = require("discord.js") module.exports = { + "enable": true, "name": "say", "description": "Let the bot print instead", "category": "me", "permissions": { "user": [PermissionsBitField.Flags.ManageMessages], "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "say (channel: name, id) <text>", - "aliases": ["s", "พูด", "ส่งข้อความ"], - async execute(client, message, args) { - const inputChannel = args[0]; - const inputText = args.slice(1).join(" "); - const textChannel = [ChannelType.GuildText, ChannelType.GuildCategory, ChannelType.GuildNews, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread, ChannelType.GuildForum]; - const channel = message.guild.channels.cache.find(channels => (channels.id === inputChannel) || (channels.name === inputChannel)); - - if (!channel) { - if (!args.join(" ")) return message.reply(client.translate.commands.say.empty); - - await message.delete(); - await message.channel.send(args.join(" ")); - message.reply({ - "content": client.translate.commands.say.success, - "ephemeral": true - }); - } else { - if (!inputText) return message.reply(client.translate.commands.say.empty); - if (channel.type === textChannel) return message.reply(client.translate.commands.say.invalid_type); - - await message.delete(); - await channel.send(inputText); - message.reply({ - "content": client.translate.commands.say.success, - "ephemeral": true - }); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -99,8 +67,6 @@ module.exports.interaction.slash = { const inputChannel = interaction.options.get("channel"); if (!inputChannel) { - if (!inputText) return await interaction.editReply(interaction.client.translate.commands.say.empty); - await interaction.editReply(inputText); await interaction.followUp({ "content": interaction.client.translate.commands.say.success, diff --git a/source/commands/music/autoplay.js b/source/commands/music/autoplay.js index 4a9e9ac3..5a3cd64d 100644 --- a/source/commands/music/autoplay.js +++ b/source/commands/music/autoplay.js @@ -1,35 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "autoplay", "description": "Turn on / off automatic music playing", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "autoplay", - "aliases": ["เล่นอัตโนมัติ", "autop", "atplay", "atp"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.autoplay.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.autoplay.not_queue_owner); - - const mode = client.music.toggleAutoplay(message); - - message.channel.send(mode ? client.translate.commands.autoplay.on : client.translate.commands.autoplay.off); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/filter.js b/source/commands/music/filter.js index 92b10270..495c0acb 100644 --- a/source/commands/music/filter.js +++ b/source/commands/music/filter.js @@ -1,131 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "filter", "description": "Filter your music to be more powerful.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "filter <option> <filters>", - "aliases": ["กรอง", "bass", "filters"], - async execute(client, message, args) { - const inputOption = args[0]; - const inputFilters = args.slice(1).map(value => value.toLowerCase()); - - const queue = client.music.getQueue(message); - const filterList = Object.keys(client.music.filters); - const filterEmbed = { - "content": client.translate.commands.filter.sound_filtering, - "embeds": [ - new EmbedBuilder() - .setTitle(client.translate.commands.filter.available_filter) - .setDescription(client.translate.commands.filter.available_filter_description.replace("%s1", filterList.length).replace("%s2", filterList.join(", "))) - .setColor("Blue") - ] - }; - - const checkFilters = (filters) => { - let count = 0; - const validFilters = []; - const invalidFilters = []; - - for (const filter of filters) { - if (filterList.includes(filter)) { - count++; - validFilters.push(filter); - } else { - count++; - invalidFilters.push(filter); - } - - if (count === filters.length) { - return { - "valid": validFilters, - "invalid": invalidFilters - }; - } - } - }; - - if (!queue) return message.reply(client.translate.commands.filter.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.filter.not_queue_owner); - - switch (inputOption) { - case "add": - if (!inputFilters.length) return message.reply(filterEmbed); - - const addCheck = checkFilters(inputFilters); - if (addCheck.invalid.length > 0) return message.reply(client.translate.commands.filter.unknown_filter.replace("%s", addCheck.invalid.join(", "))); - - await queue.filters.add(inputFilters); - message.channel.send(client.translate.commands.filter.add_filter.replace("%s", inputFilters.join(", "))); - break; - case "rm": - case "remove": - if (!inputFilters.length) return message.reply(filterEmbed); - - const removeCheck = checkFilters(inputFilters); - if (removeCheck.invalid.length > 0) return message.reply(client.translate.commands.filter.unknown_filter.replace("%s", removeCheck.invalid.join(", "))); - - await queue.filters.remove(inputFilters); - message.channel.send(client.translate.commands.filter.remove_filter.replace("%s", inputFilters.join(", "))); - break; - case "set": - if (!inputFilters.length) return message.reply(filterEmbed); - - const setCheck = checkFilters(inputFilters); - if (setCheck.invalid.length > 0) return message.reply(client.translate.commands.filter.unknown_filter.replace("%s", setCheck.invalid.join(", "))); - - await queue.filters.set(inputFilters); - message.channel.send(client.translate.commands.filter.set_filter.replace("%s", inputFilters.join(", "))); - break; - case "ava": - case "available": - const availableEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.filter.available_filter) - .setDescription(client.translate.commands.filter.available_filter_description.replace("%s1", filterList.length).replace("%s2", filterList)) - .setColor("Green"); - - message.reply({ - "content": client.translate.commands.filter.sound_filtering, - "embeds": [availableEmbed] - }); - break; - case "l": - case "list": - const filtersName = queue.filters.names.join(", "); - const filtersSize = queue.filters.names.length; - const listEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.filter.list_filter_title) - .setDescription(filtersSize ? client.translate.commands.filter.list_filter_description.replace("%s1", filtersSize).replace("%s2", filtersName) : client.translate.commands.filter.list_filter_description_empty) - .setColor("Blue"); - - message.channel.send({ - "embeds": [listEmbed] - }); - break; - case "clr": - case "cle": - case "clear": - await queue.filters.clear(); - message.channel.send(client.translate.commands.filter.clear_filter); - break; - default: - return message.reply(client.translate.commands.filter.unknown_input_option); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -193,7 +82,7 @@ module.exports.interaction.slash = { const inputOption = interaction.options.get("option").value; const inputFilters = interaction.options.get("filters").value.split(",").map(value => value.toLowerCase()); - const queue = interaction.client.music.getQueue(message); + const queue = interaction.client.music.getQueue(interaction); const filterList = Object.keys(interaction.client.music.filters); const filterEmbed = { "content": interaction.client.translate.commands.filter.sound_filtering, diff --git a/source/commands/music/join.js b/source/commands/music/join.js index 7ed98a56..a424beb4 100644 --- a/source/commands/music/join.js +++ b/source/commands/music/join.js @@ -1,6 +1,7 @@ -const { ChannelType, PermissionsBitField } = require("discord.js"); +const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "join", "description": "Join the audio channel.", "category": "music", @@ -10,59 +11,25 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.Connect ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "join (channel: name, id)", - "aliases": ["j", "เข้า", "เข้าร่วม"], - async execute(client, message, args) { - const inputChannel = args.join(" "); - - const queue = client.music.getQueue(message); - - if (queue && message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.join.another_player_is_playing); - if (!inputChannel) { - const voiceChannel = message.member.voice.channel; - const meChannel = message.guild.members.me.voice.channel; - - if (!voiceChannel) return message.reply(client.translate.commands.join.not_in_channel); - if (meChannel && meChannel.id === voiceChannel.id) return message.reply(client.translate.commands.join.already_joined); - - client.music.voices.join(voiceChannel); - message.channel.send(client.translate.commands.join.joined.replace("%s", voiceChannel.id)); - } else { - const channel = message.guild.channels.cache.find(channels => (channels.id === inputChannel) || (channels.name === inputChannel)); - - if (channel.type === ChannelType.GuildVoice) { - if (!channel) return message.reply(client.translate.commands.join.no_channel); - - client.music.voices.join(channel); - message.channel.send(client.translate.commands.join.channel_joined.replace("%s", channel.id)); - } else { - message.reply(client.translate.commands.join.not_a_voice_channel); - } - } - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { - "en-US": "join", - "th": "เข้าร่วม" - }, + "en-US": "join", + "th": "เข้าร่วม" + }, "description": module.exports.description, "description_localizations": { - "en-US": "Join the audio channel.", - "th": "เข้าร่วมช่องสัญญาณเสียง" - }, + "en-US": "Join the audio channel.", + "th": "เข้าร่วมช่องสัญญาณเสียง" + }, "options": [ { "type": 7, @@ -84,7 +51,7 @@ module.exports.interaction.slash = { }, async execute(interaction) { const inputChannel = interaction.options.get("channel"); - + const queue = interaction.client.music.getQueue(interaction); if (queue && interaction.user.id !== queue.songs[0].user.id && queue.autoplay === false) return await interaction.editReply(interaction.client.translate.commands.join.another_player_is_playing); diff --git a/source/commands/music/jump.js b/source/commands/music/jump.js index 0839a1ec..e0a54a61 100644 --- a/source/commands/music/jump.js +++ b/source/commands/music/jump.js @@ -1,42 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "jump", "description": "Skip to the selected queue number", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "jump <number>", - "aliases": ["skipto", "ข้ามไปที่"], - async execute(client, message, args) { - const inputAmount = parseInt(args[0]); - - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.jump.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.jump.not_queue_owner); - if (!inputAmount) return message.reply(client.translate.commands.jump.no_input); - if (inputAmount <= 0) return message.reply(client.translate.commands.jump.too_low); - if (inputAmount > queue.songs.length) return message.reply(client.translate.commands.jump.too_much); - - try { - client.music.jump(message, inputAmount); - } catch (error) { - message.reply(client.translate.commands.jump.can_not_jump); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/leave.js b/source/commands/music/leave.js index e7ad3601..2f1bbde7 100644 --- a/source/commands/music/leave.js +++ b/source/commands/music/leave.js @@ -1,38 +1,20 @@ const { PermissionsBitField } = require("discord.js") module.exports = { + "enable": true, "name": "leave", "description": "Exits the current audio channel.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "leave", - "aliases": ["l", "dc", "dis", "disconnect", "ออก", "ออกจาก"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - const meChannel = message.guild.members.me.voice.channel; - - if (queue && message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.leave.another_player_is_playing); - if (!meChannel) return message.reply(client.translate.commands.leave.not_in_any_channel); - - const connection = client.music.voices.get(meChannel.guild); - - connection.leave(meChannel.guild); - message.channel.send(client.translate.commands.leave.now_leave); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/lyrics.js b/source/commands/music/lyrics.js index 0053b15f..1f2bb0ff 100644 --- a/source/commands/music/lyrics.js +++ b/source/commands/music/lyrics.js @@ -2,54 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const lyricsFinder = require("lyrics-finder"); module.exports = { + "enable": true, "name": "lyrics", "description": "Get lyrics for the currently playing song", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "lyrics", - "aliases": ["ly", "เนื้อร้อง"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.lyrics.no_queue); - - let lyrics; - const queueName = queue.songs.map((song, id) => song.name); - - try { - lyrics = await lyricsFinder(queueName, ""); - - if (!lyrics) lyrics = client.translate.commands.lyrics.can_not_find_lyrics.replace("%s", queueName); - } catch (error) { - lyrics = client.translate.commands.lyrics.can_not_find_lyrics.replace("%s", queueName); - } - - const authorUsername = message.author.username; - const authorAvatar = message.author.displayAvatarURL(); - const lyricsEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.lyrics.playing_lyrics) - .setDescription("```" + lyrics + "```") - .setColor("Blue") - .setTimestamp() - .setFooter({ "text": authorUsername, "iconURL": authorAvatar }); - - message.channel.send({ - "embeds": [lyricsEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/musicInfo.js b/source/commands/music/musicInfo.js index 6eb13865..7e16c8eb 100644 --- a/source/commands/music/musicInfo.js +++ b/source/commands/music/musicInfo.js @@ -1,83 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "musicInfo", "description": "See information for the currently playing song", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "musicInfo", - "aliases": ["musicinfo", "minfo", "msinfo", "musicif", "ข้อมูลเพลง", "ข้อมูลของเพลง"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.musicInfo.no_queue); - - const queueName = queue.songs[0].name; - const queueTimestamp = queue.songs[0].formattedDuration; - const queueId = queue.songs[0].id; - const queueURL = queue.songs[0].url; - const queueStreamURL = queue.songs[0].streamURL; - const queueUploaderName = queue.songs[0].uploader.name; - const queueUploaderURL = queue.songs[0].uploader.url; - const queueThumbnail = queue.songs[0].thumbnail; - - const musicInfoEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.musicInfo.detail) - .setImage(queueThumbnail) - .setColor("Blue") - .setTimestamp() - .addFields( - [ - { - "name": client.translate.commands.musicInfo.music_name, - "value": queueName, - "inline": true - }, - { - "name": client.translate.commands.musicInfo.uploader, - "value": "[" + queueUploaderName + "](" + queueUploaderURL + ")", - "inline": true - }, - { - "name": client.translate.commands.musicInfo.duration, - "value": queueTimestamp, - "inline": true - }, - { - "name": client.translate.commands.musicInfo.id, - "value": queueId, - "inline": true - }, - { - "name": client.translate.commands.musicInfo.link, - "value": queueURL, - "inline": true - }, - { - "name": client.translate.commands.musicInfo.download_link, - "value": "[Google Video](" + queueStreamURL + ")", - "inline": true - } - ] - ); - - message.channel.send({ - "embeds": [musicInfoEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/music/nowPlaying.js b/source/commands/music/nowPlaying.js index abcf0262..768a5424 100644 --- a/source/commands/music/nowPlaying.js +++ b/source/commands/music/nowPlaying.js @@ -1,100 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "nowPlaying", "description": "Check the music that is currently playing.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "nowPlaying", - "aliases": ["nowplaying", "np", "กำลังเล่น"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.nowPlaying.no_queue); - - const queueName = queue.songs[0].name; - const queueAuthorUid = queue.songs[0].user.id; - const queueAuthorUsername = queue.songs[0].user.username; - const queueAuthorAvatar = queue.songs[0].user.avatar; - const queueCreatedTimestamp = queue.createdTimestamp; - const avatarURL = "https://cdn.discordapp.com/avatars/" + queueAuthorUid + "/" + queueAuthorAvatar + ".webp"; - - const musicURL = queue.songs[0].url; - const musicThumbnail = queue.songs[0].thumbnail; - - let durationLine; - const duration = queue.songs[0].duration; - const durationCurrent = Math.floor(queue.currentTime / 1000); - const durationPercentage = Math.round((durationCurrent / duration) * 100); - if (durationPercentage >= 0 && durationPercentage <= 5) durationLine = "🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 5 && durationPercentage <= 10) durationLine = "▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 10 && durationPercentage <= 15) durationLine = "▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 15 && durationPercentage <= 20) durationLine = "▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 20 && durationPercentage <= 25) durationLine = "▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 25 && durationPercentage <= 30) durationLine = "▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 30 && durationPercentage <= 35) durationLine = "▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 35 && durationPercentage <= 40) durationLine = "▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 40 && durationPercentage <= 45) durationLine = "▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 45 && durationPercentage <= 50) durationLine = "▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 50 && durationPercentage <= 55) durationLine = "▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 55 && durationPercentage <= 60) durationLine = "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 60 && durationPercentage <= 65) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬"; - if (durationPercentage >= 65 && durationPercentage <= 70) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬"; - if (durationPercentage >= 70 && durationPercentage <= 75) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"; - if (durationPercentage >= 75 && durationPercentage <= 80) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬"; - if (durationPercentage >= 80 && durationPercentage <= 85) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬"; - if (durationPercentage >= 85 && durationPercentage <= 90) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬"; - if (durationPercentage >= 90 && durationPercentage <= 95) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬"; - if (durationPercentage >= 95 && durationPercentage <= 100) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘"; - - const durationFormat = queue.songs[0].formattedDuration; - const durationCurrentFormat = queue.formattedCurrentTime; - const durationCount = durationCurrentFormat + " / " + durationFormat + " - " + duration; - - const musicPaused = client.music.paused ? "▶" : "▐▐"; - const musicAction = "◄◄⠀" + musicPaused + "⠀►►"; - - let musicControl; - const musicVolume = queue.volume; - if (musicVolume === 0) musicControl = "🔇 ○───"; - if (musicVolume >= 0 && musicVolume <= 30) musicControl = "🔈 ─○──"; - if (musicVolume >= 30 && musicVolume <= 70) musicControl = "🔉 ──○─"; - if (musicVolume >= 70 && musicVolume <= 100) musicControl = "🔊 ───○"; - - const musicRepeat = queue.repeatMode ? queue.repeatMode === 2 ? "🔂" : "🔁" : ""; - - const musicAutoplay = queue.autoplay ? "\n" + client.translate.commands.nowPlaying.autoplay : ""; - - const musicFilter = queue.filters.names.length > 0 ? "\n" + client.translate.commands.nowPlaying.filter.replace("%s", queue.filters.names.join(", ")) : ""; - - const musicDisplay = durationLine + "\n" + durationCount + " " + musicAction + " " + musicControl + " " + musicRepeat + musicAutoplay + musicFilter; - - const nowPlayingEmbed = new EmbedBuilder() - .setTitle(queueName) - .setURL(musicURL) - .setDescription(musicDisplay) - .setThumbnail(musicThumbnail) - .setColor("Blue") - .setTimestamp(queueCreatedTimestamp) - .setFooter({ "text": client.translate.commands.nowPlaying.owner_this_queue.replace("%s", queueAuthorUsername), "iconURL": avatarURL }); - - message.channel.send({ - "embeds": [nowPlayingEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/music/pause.js b/source/commands/music/pause.js index 5db8ff43..27dea760 100644 --- a/source/commands/music/pause.js +++ b/source/commands/music/pause.js @@ -1,35 +1,20 @@ const { PermissionsBitField } = require("discord.js") module.exports = { + "enable": true, "name": "pause", "description": "Temporarily stop playing songs in the queue.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "pause", - "aliases": ["pu", "หยุดชั่วคราว"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.pause.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.pause.not_owner); - if (queue.paused) return message.reply(client.translate.commands.pause.not_paused); - - client.music.pause(message); - message.channel.send(client.translate.commands.pause.paused); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/play.js b/source/commands/music/play.js index fc6845a9..29a4fd62 100644 --- a/source/commands/music/play.js +++ b/source/commands/music/play.js @@ -2,6 +2,7 @@ const { PermissionsBitField } = require("discord.js"); const { catchError } = require("../../utils/consoleUtils"); module.exports = { + "enable": true, "name": "play", "description": "Sing to listen", "category": "music", @@ -12,40 +13,14 @@ module.exports = { PermissionsBitField.Flags.Speak, PermissionsBitField.Flags.Connect ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "play <source: name, id, link>", - "aliases": ["เล่น", "p", "เพลง"], - async execute(client, message, args) { - const inputSource = args.join(" "); - const voiceChannel = message.member.voice.channel; - - if (!inputSource) return message.reply(client.translate.commands.play.no_song_input); - if (!voiceChannel) return message.reply(client.translate.commands.play.not_in_channel); - - try { - client.music.play(voiceChannel, inputSource, { - "member": message.member, - "textChannel": message.channel, - message - }); - } catch (error) { - const connection = client.music.voices.get(voiceChannel.guild); - - connection.leave(voiceChannel.guild); - catchError(client, message, module.exports.name, error); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/previous.js b/source/commands/music/previous.js index fd2bf5d8..b61f9ee6 100644 --- a/source/commands/music/previous.js +++ b/source/commands/music/previous.js @@ -1,6 +1,7 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "previous", "description": "Return to the previous song.", "category": "music", @@ -9,30 +10,14 @@ module.exports = { PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.Connect ] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "previous", - "aliases": ["pv", "เพลงก่อนหน้า"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.previous.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.previous.not_owner); - if (!queue.previousSongs) return message.reply(client.translate.commands.previous.no_previous_song_queue); - - client.music.previous(message); - message.channel.send(client.translate.commands.previous.previous); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/quality.js b/source/commands/music/quality.js index 7e2314fa..cb64042a 100644 --- a/source/commands/music/quality.js +++ b/source/commands/music/quality.js @@ -2,51 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { StreamType } = require("distube"); module.exports = { + "enable": true, "name": "quality", "description": "Try this command if you have sound problems or people with poor internet connection.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "quality <options: 0, 1>", - "aliases": ["คุณภาพ", "ql"], - async execute(client, message, args) { - const inputOption = args[0]; - - const quality = client.music.options.streamType === 0 ? client.translate.commands.quality.focus_on_high_quality : client.translate.commands.quality.low_efficiency; - const adviceEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.quality.advice_embed_title) - .setDescription(client.translate.commands.quality.advice_embed_description.replace("%s", quality)) - .setFooter({ "text": client.translate.commands.quality.advice_embed_footer_text, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/microsoft/310/light-bulb_1f4a1.png" }) - .setColor("Blue") - .setTimestamp(); - - if (!inputOption) return message.reply({ "embeds": [adviceEmbed] }); - - switch (inputOption) { - case "0": - client.music.options.streamType = StreamType.OPUS; - message.channel.send(client.translate.commands.quality.opus_mode_selected); - break; - case "1": - client.music.options.streamType = StreamType.RAW; - message.channel.send(client.translate.commands.quality.raw_mode_selected); - break; - default: - message.reply({ "embeds": [adviceEmbed] }); - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/queue.js b/source/commands/music/queue.js index 06d613de..2cda9548 100644 --- a/source/commands/music/queue.js +++ b/source/commands/music/queue.js @@ -1,100 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "queue", "description": "Check songs in the queue", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "queue", - "aliases": ["q", "คิว"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.queue.no_queue); - - const queueList = queue.songs.map((song, id) => id + ". " + song.name + " - `" + song.formattedDuration + "`").slice(1, 10).join("\n"); - const queuePreviousList = queue.previousSongs.map((song, id) => (id + 1) + ". " + song.name + " - `" + song.formattedDuration + "`").slice(0, 10).join("\n") - const queueCreatedTimestamp = queue.createdTimestamp; - const queueAuthorUid = queue.songs[0].user.id; - const queueAuthorUsername = queue.songs[0].user.username; - const queueAuthorAvatar = queue.songs[0].user.avatar; - const avatarURL = "https://cdn.discordapp.com/avatars/" + queueAuthorUid + "/" + queueAuthorAvatar + ".webp"; - - const musicCurrent = queue.songs[0].name; - const musicURL = queue.songs[0].url; - - let durationLine; - const duration = queue.songs[0].duration; - const durationCurrent = queue.currentTime; - const durationPercentage = Math.round((durationCurrent / duration) * 100); - if (durationPercentage >= 0 && durationPercentage <= 5) durationLine = "🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 5 && durationPercentage <= 10) durationLine = "▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 10 && durationPercentage <= 15) durationLine = "▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 15 && durationPercentage <= 20) durationLine = "▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 20 && durationPercentage <= 25) durationLine = "▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 25 && durationPercentage <= 30) durationLine = "▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 30 && durationPercentage <= 35) durationLine = "▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 35 && durationPercentage <= 40) durationLine = "▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 40 && durationPercentage <= 45) durationLine = "▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 45 && durationPercentage <= 50) durationLine = "▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 50 && durationPercentage <= 55) durationLine = "▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 55 && durationPercentage <= 60) durationLine = "▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬▬"; - if (durationPercentage >= 60 && durationPercentage <= 65) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬▬"; - if (durationPercentage >= 65 && durationPercentage <= 70) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬▬"; - if (durationPercentage >= 70 && durationPercentage <= 75) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬▬"; - if (durationPercentage >= 75 && durationPercentage <= 80) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬▬"; - if (durationPercentage >= 80 && durationPercentage <= 85) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬▬"; - if (durationPercentage >= 85 && durationPercentage <= 90) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬▬"; - if (durationPercentage >= 90 && durationPercentage <= 95) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘▬"; - if (durationPercentage >= 95 && durationPercentage <= 100) durationLine = "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬🔘"; - - const durationFormat = queue.songs[0].formattedDuration; - const durationCurrentFormat = queue.formattedCurrentTime; - const durationCount = durationCurrentFormat + " / " + durationFormat + " - " + duration; - - const musicPaused = client.music.paused ? "▶" : "▐▐"; - const musicAction = " ◄◄⠀" + musicPaused + "⠀►► "; - - let musicControl; - const musicVolume = queue.volume; - if (musicVolume === 0) musicControl = "🔇 ○───"; - if (musicVolume >= 0 && musicVolume <= 30) musicControl = "🔈 ─○──"; - if (musicVolume >= 30 && musicVolume <= 70) musicControl = "🔉 ──○─"; - if (musicVolume >= 70 && musicVolume <= 100) musicControl = "🔊 ───○"; - - const musicRepeat = queue.repeatMode === 0 ? "" : queue.repeatMode === 1 ? "🔁" : "🔂"; - - const musicAutoplay = queue.autoplay ? "\n" + client.translate.commands.queue.autoplay : ""; - - const musicFilter = queue.filters.names.length > 0 ? "\n" + client.translate.commands.nowPlaying.filter.replace("%s", queue.filters.names.join(", ")) : ""; - - const musicDisplay = durationLine + "\n" + durationCount + " " + musicAction + " " + musicControl + " " + musicRepeat + musicAutoplay + musicFilter; - - const queueEmbed = new EmbedBuilder() - .setTitle(musicCurrent) - .setURL(musicURL) - .setDescription(queue.songs.length === 1 ? musicDisplay : musicDisplay + "\n\n" + client.translate.commands.queue.waiting_in_queue + "\n" + queueList + (queue.previousSongs.length === 1 ? "\n\n" + client.translate.commands.queue.previous_queue + "\n" + queuePreviousList : "")) - .setColor("Blue") - .setTimestamp(queueCreatedTimestamp) - .setFooter({ "text": client.translate.commands.queue.owner_this_queue.replace("%s", queueAuthorUsername), "iconURL": avatarURL }); - - message.channel.send({ - "embeds": [queueEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/queueStatus.js b/source/commands/music/queueStatus.js index b1de5e0d..ece1e011 100644 --- a/source/commands/music/queueStatus.js +++ b/source/commands/music/queueStatus.js @@ -1,87 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "queueStatus", "description": "Check the status of the current song queue.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "queueStatus", - "aliases": ["qstatus", "qs", "สถานะคิว"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.queueStatus.no_queue); - - const musicPaused = client.music.paused ? client.translate.commands.queueStatus.paused : client.translate.commands.queueStatus.playing; - const queueVolume = queue.volume; - const queueFilter = queue.filters.names.length > 0 ? queue.filters.names.join(", ") : ""; - const queueDuration = queue.songs[0].duration; - const queueDurationCurrent = queue.currentTime; - const queueRepeat = queue.repeatMode ? queue.repeatMode === 2 ? client.translate.commands.queueStatus.repeat_this_queue : client.translate.commands.queueStatus.repeat_this_song : client.translate.commands.queueStatus.repeat_off; - const queueAutoplay = queue.autoplay ? client.translate.commands.queueStatus.on : client.translate.commands.queueStatus.off; - const queueCreatedTimestamp = queue.createdTimestamp; - const queueAuthorUid = queue.songs[0].user.id; - const queueAuthorUsername = queue.songs[0].user.username; - const queueAuthorAvatar = queue.songs[0].user.avatar; - const avatarURL = "https://cdn.discordapp.com/avatars/" + queueAuthorUid + "/" + queueAuthorAvatar + ".webp"; - - const queueStatusEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.queueStatus.queue_status) - .setColor("Blue") - .setTimestamp(queueCreatedTimestamp) - .setFooter({ "text": client.translate.commands.queueStatus.owner_this_queue.replace("%s", queueAuthorUsername), "iconURL": avatarURL }) - .addFields( - [ - { - "name": client.translate.commands.queueStatus.now, - "value": "```" + musicPaused + "```", - "inline": true - }, - { - "name": client.translate.commands.queueStatus.volume, - "value": "```" + queueVolume + "```", - "inline": true - }, - { - "name": client.translate.commands.queueStatus.filter, - "value": "```" + queueFilter + "```", - "inline": true - }, - { - "name": client.translate.commands.queueStatus.repeat, - "value": "```" + queueRepeat + "```", - "inline": true - }, - { - "name": client.translate.commands.queueStatus.autoplay, - "value": "```" + queueAutoplay + "```", - "inline": true - }, - { - "name": client.translate.commands.queueStatus.duration, - "value": "```" + queueDurationCurrent + " / " + queueDuration + "```", - "inline": true - } - ] - ); - - message.channel.send({ - "embeds": [queueStatusEmbed] - }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { diff --git a/source/commands/music/remove.js b/source/commands/music/remove.js index 6de9c113..60ffac37 100644 --- a/source/commands/music/remove.js +++ b/source/commands/music/remove.js @@ -1,38 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "remove", "description": "Remove song from the queue", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "remove <number>", - "aliases": ["rm", "rq", "ลบ", "ลบคิว"], - async execute(client, message, args) { - const inputAmount = parseInt(args[0]); - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.remove.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.remove.not_owner); - if (!inputAmount) return message.reply(client.translate.commands.remove.remove_guide.replace("%s", (client.config.prefix + module.exports.help.name))); - if (inputAmount <= 0) return message.reply(client.translate.commands.remove.too_little); - if (inputAmount >= queue.songs.length) return message.reply(client.translate.commands.remove.too_much); - - const song = queue.songs.splice(inputAmount, 1); - message.channel.send(client.translate.commands.remove.removed.replace("%s", song[0].name)); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/repeat.js b/source/commands/music/repeat.js index 7246ed7e..dfc7737b 100644 --- a/source/commands/music/repeat.js +++ b/source/commands/music/repeat.js @@ -1,38 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "repeat", "description": "Toggle repeating playback mode.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "repeat <mode: 0, 1, 2>", - "aliases": ["loop", "วน", "ทำซ้ำ"], - async execute(client, message, args) { - const inputMode = parseInt(args[0]); - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.repeat.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.repeat.not_owner); - if (!inputMode) return message.reply(client.translate.commands.repeat.repeat_guide); - if (inputMode <= 0) return message.reply(client.translate.commands.repeat.too_little); - if (inputMode >= 2) return message.reply(client.translate.commands.repeat.too_much); - - const mode = client.music.setRepeatMode(message, inputMode); - message.channel.send(client.translate.commands.repeat.repeated.replace("%s", (mode ? mode == 2 ? client.translate.commands.repeat.repeat_queue : client.translate.commands.repeat.repeat_song : client.translate.commands.repeat.off))); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/resume.js b/source/commands/music/resume.js index 1bb943f0..73ad6509 100644 --- a/source/commands/music/resume.js +++ b/source/commands/music/resume.js @@ -1,35 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "resume", "description": "Continue playing music from the beginning.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "resume", - "aliases": ["rs", "เล่นต่อ", "ต่อ"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.resume.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.resume.not_owner); - if (!queue.paused) return message.reply(client.translate.commands.resume.now_playing); - - client.music.resume(message); - message.channel.send(client.translate.commands.resume.resumed); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/search.js b/source/commands/music/search.js index 70ef9c43..3118bc58 100644 --- a/source/commands/music/search.js +++ b/source/commands/music/search.js @@ -3,193 +3,20 @@ const { SoundCloudPlugin } = require("@distube/soundcloud"); const { catchError } = require("../../utils/consoleUtils"); module.exports = { + "enable": true, "name": "search", "description": "Search for the song or playlist you want.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "search [platform: youtube, soundcloud] [type: track, playlist] <song>", - "aliases": ["ค้นหา", "sh"], - async execute(client, message, args) { - const limit = 10; - const from = ["youtube", "soundcloud"]; - const types = ["track", "playlist"]; - const voiceChannel = message.member.voice.channel; - - const filter = (content) => { - const index = []; - if (!content.content) return; - if (content.author.id !== message.author.id) return; - for (let i = 0; i < limit; i++) index.push((i + 1).toString()); - return index.includes(content.content) || !index.includes(content.content); - } - - const searcher = async (platform, results) => { - let index = 0; - const data = results.map((song) => { - const name = song.name; - const uploaderName = song.uploader ? song.uploader.name ? " : **" + song.uploader.name + "**" : "" : ""; - const formattedDuration = song.formattedDuration ? "`" + song.formattedDuration + "`" : ""; - return "**" + (++index) + "**" + ". " + name + " " + formattedDuration + uploaderName; - }).join("\n"); - - const authorUsername = message.author.username; - const authorAvatar = message.author.displayAvatarURL(); - const searchEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.search.searching.replace("%s", results[0].type === "video" || results[0].type === "track" ? client.translate.commands.search.song_type : client.translate.commands.search.playlist_type)) - .setDescription(client.translate.commands.search.timer_choose.replace("%s", results[0].type === "video" || results[0].type === "track" ? client.translate.commands.search.song_type : client.translate.commands.search.playlist_type)) - .setColor(platform === "youtube" ? 13632027 : 16296490) - .setTimestamp() - .setAuthor({ "name": platform === "youtube" ? "YouTube" : "SoundCloud", "url": platform === "youtube" ? "https://www.youtube.com/" : "https://soundcloud.com/", "iconURL": platform === "youtube" ? "https://www.youtube.com/s/desktop/6007d895/img/favicon_144x144.png" : "https://a-v2.sndcdn.com/assets/images/sc-icons/ios-a62dfc8fe7.png" }) - .setFooter({ "text": authorUsername, "iconURL": authorAvatar }) - .addFields( - [ - { - "name": client.translate.commands.search.title_results.replace("%s", results[0].type === "video" || results[0].type === "track" ? client.translate.commands.search.song_type : client.translate.commands.search.playlist_type), - "value": data - } - ] - ); - - message.channel.send({ - "embeds": [searchEmbed] - }); - - let collection; - - try { - collection = await message.channel.awaitMessages({ - filter, - "max": 1, - "time": 60000, - "errors": ["time"] - }); - } catch (error) { - message.reply(client.translate.commands.search.search_cancelled); - } - - if (!collection) return; - - const returnMessage = collection.first(); - const contentNumber = parseInt(returnMessage.content); - const contentIndex = parseInt(returnMessage.content) - 1; - - if (!contentNumber || (!contentNumber && contentNumber < index || contentNumber > index)) return message.channel.send(client.translate.commands.search.invalid_number); - - message.channel.send(client.translate.commands.search.get_list_of_songs); - try { - client.music.play(voiceChannel, results[contentIndex], { - "member": message.member, - "textChannel": message.channel, - message - }); - } catch (error) { - const connection = client.music.voices.get(voiceChannel.guild); - - connection.leave(voiceChannel.guild); - catchError(client, message, module.exports.help.name, error); - } - } - - if (!args[0]) return message.reply(client.translate.commands.search.no_search_input); - if (!voiceChannel) return message.reply(client.translate.commands.search.user_not_in_channel); - if (from.includes(args[0].toLowerCase())) { - switch (args[0].toLowerCase()) { - case "youtube": - if (args[2] && types.includes(args[1].toLowerCase())) { - if (args[1].toLowerCase() === "video") args[1] = "track"; - if (!types.includes(args[1].toLowerCase())) return message.reply(client.translate.commands.search.type_of_list.replace("%s", args[1])); - if (args[1] === "track") args[1] = "video"; - - try { - const results = await client.music.search(args.slice(2).join(" "), { - "limit": limit, - "type": args[1].toLowerCase(), - "safeSearch": true - }); - - searcher(args[0].toLowerCase(), results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } else { - try { - const results = await client.music.search(args.slice(1).join(" "), { - "limit": limit, - "safeSearch": true - }); - - searcher(args[0].toLowerCase(), results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } - break; - case "soundcloud": - if (args[2] && types.includes(args[1].toLowerCase())) { - if (!types.includes(args[1].toLowerCase())) return message.reply(client.translate.commands.search.type_of_list.replace("%s", args[1])); - - try { - const results = await SoundCloudPlugin.search(args.slice(2).join(" "), args[1].toLowerCase()); - - searcher(args[0].toLowerCase(), results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } else { - try { - const results = await SoundCloudPlugin.search(args.slice(1).join(" ")); - - searcher(args[0].toLowerCase(), results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } - break; - default: - message.reply(client.translate.commands.search.platform_not_supported); - } - } else if (types.includes(args[0].toLowerCase())) { - if (args[0].toLowerCase() === "video") args[0] = "track"; - if (!types.includes(args[0].toLowerCase())) return message.reply(client.translate.commands.search.type_of_list.replace("%s", args[1])); - if (args[0] === "track") args[0] = "video"; - - try { - const results = await client.music.search(args.slice(1).join(" "), { - "limit": limit, - "type": args[0].toLowerCase(), - "safeSearch": true - }); - - searcher("youtube", results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } else { - try { - const results = await client.music.search(args.join(" "), { - "limit": limit, - "safeSearch": true - }); - - searcher("youtube", results); - } catch { - message.channel.send(client.translate.commands.search.no_results); - } - } + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/seek.js b/source/commands/music/seek.js index 65b1c3e9..8fb99cc3 100644 --- a/source/commands/music/seek.js +++ b/source/commands/music/seek.js @@ -1,42 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "seek", "description": "Change the duration of the currently playing song", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "seek <second>", - "aliases": ["ช่วง", "duration"], - async execute(client, message, args) { - const inputSecond = parseInt(args[0]); - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.seek.no_queue); - - const queueDuration = queue.songs.map((song, id) => song.duration); - const queueFormatDuration = queue.songs.map((song, id) => song.formatDuration); - - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.seek.not_owner); - if (!inputSecond) return message.reply(client.translate.commands.seek.seek_guide.replace("%s", queueDuration)); - if (inputSecond <= 0) return message.reply(client.translate.commands.seek.too_little); - if (inputSecond >= queueDuration.join()) return message.reply(client.translate.commands.seek.too_much.replace("%s", queueFormatDuration)); - - client.music.seek(message, (inputSecond * 100)); - message.channel.send(client.translate.commands.seek.sought); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/shuffle.js b/source/commands/music/shuffle.js index 258bc5d7..ce9b2875 100644 --- a/source/commands/music/shuffle.js +++ b/source/commands/music/shuffle.js @@ -1,34 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "shuffle", "description": "Shuffle queue", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "shuffle", - "aliases": ["shf", "สับเปลี่ยน", "สลับ", "เปลี่ยน"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.shuffle.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.shuffle.not_owner); - - client.music.shuffle(message); - message.channel.send(client.translate.commands.shuffle.now_shuffle); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/skip.js b/source/commands/music/skip.js index c8a6903a..36d63867 100644 --- a/source/commands/music/skip.js +++ b/source/commands/music/skip.js @@ -1,34 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "skip", "description": "Skip the currently playing song.", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "skip", - "aliases": ["sk", "ข้าม"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.skip.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.skip.not_owner); - - client.music.skip(message); - message.channel.send(client.translate.commands.skip.skipped); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/stop.js b/source/commands/music/stop.js index 81c2539a..e71f83bc 100644 --- a/source/commands/music/stop.js +++ b/source/commands/music/stop.js @@ -1,34 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "stop", "description": "Stop playing current song", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "stop", - "aliases": ["st", "หยุด", "หยุดเล่น"], - async execute(client, message, args) { - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.stop.no_queue); - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.stop.not_owner); - - client.music.stop(message); - message.channel.send(client.translate.commands.stop.stopped); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/music/volume.js b/source/commands/music/volume.js index 35e9acd4..28b22d25 100644 --- a/source/commands/music/volume.js +++ b/source/commands/music/volume.js @@ -1,41 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "volume", "description": "Adjust the music volume", "category": "music", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "volume [percent]", - "aliases": ["vl", "ระดับเสียง", "ระดับเพลง", "ปรับเสียง"], - async execute(client, message, args) { - const inputPercent = parseInt(args[0]); - const queue = client.music.getQueue(message); - - if (!queue) return message.reply(client.translate.commands.volume.no_queue); - - const queueVolume = queue.volume; - - if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.volume.not_owner); - if (!inputPercent) return message.reply(client.translate.commands.volume.this_volume.replace("%s", queueVolume)); - if (inputPercent < 0) return message.reply(client.translate.commands.volume.too_little); - if (inputPercent > 100) return message.reply(client.translate.commands.volume.too_much); - - client.music.setVolume(message, inputPercent); - message.channel.send(client.translate.commands.volume.adjusted.replace("%s", inputPercent)); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/owner/reboot.js b/source/commands/owner/reboot.js index aac9d1f4..3412eed5 100644 --- a/source/commands/owner/reboot.js +++ b/source/commands/owner/reboot.js @@ -1,55 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "reboot", "description": "Reboot the bot system.", "category": "owner", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "reboot (password)", - "aliases": ["re", "restart", "เริ่มระบบใหม่"], - async execute(client, message, args) { - if (message.member.id !== client.config.owner) return message.reply(client.translate.commands.reboot.not_owner); - - const inputPassword = args[0]; - - if (!client.temp.password) { - const owner = await client.users.fetch(client.config.owner); - let chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - let password = ""; - - client.temp.password = 0; - - for (let i = 0; i <= 12; i++) { - let randomNumber = Math.floor(Math.random() * chars.length); - password += chars.substring(randomNumber, randomNumber + 1); - } - - client.temp.password = password; - - owner.send("**:arrows_counterclockwise: มีคำขอสำหรับการรีสตาร์ทระบบใหม่ค่าา!!**\nเพื่อยืนยันว่าเป็นท่านกรุณากรอกรหัสผ่านนี้ในเซิร์ฟเวอร์ที่ท่านเรียกใช้คำสั่ง\nท่านสามารถละเว้นได้หากไม่ต้องการดำเนินการต่อ\nขอขอบคุณที่ท่านยังดูแลฉันมาจนถึงทุกวันนี้นะคะ :)\n||%s||".replace("%s", password)); - } - if (!inputPassword) return message.reply(client.translate.commands.reboot.password_is_required); - if (inputPassword !== client.temp.password) return message.reply(client.translate.commands.reboot.password_is_incorrect); - - message.channel.send(client.translate.commands.reboot.rebooting).then(async (msg) => { - await client.destroy(); - client.login(client.config.token); - msg.edit(client.translate.commands.reboot.now_reboot); - }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/owner/shutdown.js b/source/commands/owner/shutdown.js index 66418edd..b0f62c7c 100644 --- a/source/commands/owner/shutdown.js +++ b/source/commands/owner/shutdown.js @@ -1,56 +1,20 @@ const { PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "shutdown", "description": "Shutdown the bot system.", "category": "owner", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "shutdown (password)", - "aliases": ["sd", "ปิดระบบ"], - async execute(client, message, args) { - if (message.member.id !== client.config.owner) return message.reply(client.translate.commands.shutdown.not_owner); - - const inputPassword = args[0]; - - if (!client.temp.password) { - const owner = await client.users.fetch(client.config.owner); - let chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - let password = ""; - - client.temp.password = 0; - - for (let i = 0; i <= 12; i++) { - let randomNumber = Math.floor(Math.random() * chars.length); - password += chars.substring(randomNumber, randomNumber + 1); - } - - client.temp.password = password; - - owner.send("**:red_circle: มีคำขอสำหรับการปิดระบบค่าา!!**\nเพื่อยืนยันว่าเป็นท่านกรุณากรอกรหัสผ่านนี้ในเซิร์ฟเวอร์ที่ท่านเรียกใช้คำสั่ง\nท่านสามารถละเว้นได้หากไม่ต้องการดำเนินการต่อ\nขอขอบคุณที่ท่านยังดูแลฉันมาจนถึงทุกวันนี้นะคะ :)\n||%s||".replace("%s", password)); - } - if (!inputPassword) return message.reply(client.translate.commands.shutdown.password_is_required); - if (inputPassword !== client.temp.password) return message.reply(client.translate.commands.shutdown.password_is_incorrect); - - message.channel.send(client.translate.commands.shutdown.shutting_down).then((msg) => { - msg.edit(client.translate.commands.shutdown.now_shutdown).then(async () => { - await client.destroy(); - process.exit(); - }); - }); - } -} - -module.exports.interaction = { - "enable": true + "function": { + "command": {} + } }; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { diff --git a/source/commands/settings/setCommand.js b/source/commands/settings/setCommand.js index 54a0b130..be8208d8 100644 --- a/source/commands/settings/setCommand.js +++ b/source/commands/settings/setCommand.js @@ -2,81 +2,21 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { getDatabase, ref, child, update } = require("firebase/database"); module.exports = { + "enable": true, "name": "setCommand", "description": "Set the bot prefix for the server.", "category": "settings", "permissions": { "user": [PermissionsBitField.Flags.ManageGuild], "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "setCommand <options: enable, disable> <command>", - "aliases": ["setcommand", "cmd", "คำสั่ง"], - async execute(client, message, args) { - const input = args.join(" "); - const inputOption = args[0] ? args[0].toLowerCase() : ""; - const inputCommand = args[1]; - - let commands; - const guildID = message.guild.id; - const prefix = client.config.prefix; - const commandsRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "commands"); - - if (!input) { - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const noInputEmbed = new EmbedBuilder() - .setTitle("🪄 คำสั่ง") - .setDescription( - client.translate.commands.setCommand.description - .replace("%s1", client.commands.size) - .replace("%s2", client.commands.map(dirs => dirs.command.enable ? "`" + dirs.name + "`" : "||" + dirs.name + "||").join(", ")) - .replace("%s3", (prefix + module.exports.command.usage)) - .replace("%s4", ("/" + module.exports.command.usage)) - ) - .setColor(clientColor) - .setTimestamp() - .setFooter({ "text": client.translate.commands.setCommand.data_at }); - - return message.channel.send({ - "embeds": [noInputEmbed] - }); - } - if (!inputCommand) return message.reply(client.translate.commands.setCommand.command_input_empty); - if (inputCommand.toLowerCase() === module.exports.name.toLowerCase()) return message.reply(client.translate.commands.setCommand.can_not_manage_this_command); - if (client.commands.has(inputCommand)) commands = client.commands.get(inputCommand); - if (client.aliases.has(inputCommand)) commands = client.commands.get(client.aliases.get(inputCommand)); - if (!commands) return message.reply(client.translate.commands.setCommand.command_not_found); - - switch (inputOption) { - case "enable": - commands.command.enable = true; - - update(child(commandsRef, inputCommand), true).then(() => { - message.channel.send(client.translate.commands.setCommand.enabled.replace("%s", inputCommand)); - }); - break; - case "disable": - commands.command.enable = false; - - update(child(commandsRef, inputCommand), false).then(() => { - message.channel.send(client.translate.commands.setCommand.disabled.replace("%s", inputCommand)); - }); - break; - default: - return message.reply(client.translate.commands.setCommand.invalid_option.replace("%s", inputOption)); - } + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -161,24 +101,22 @@ module.exports.interaction.slash = { let commands; const guildID = interaction.guild.id; - const prefix = interaction.client.config.prefix; const commandsRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "commands"); if (subCommand === "info") { const clientFetch = await interaction.client.user.fetch(); const clientColor = clientFetch.accentColor; const noInputEmbed = new EmbedBuilder() - .setTitle("🪄 คำสั่ง") + .setTitle(interaction.client.translate.commands.setCommand.title) .setDescription( interaction.client.translate.commands.setCommand.description .replace("%s1", interaction.client.commands.size) .replace("%s2", interaction.client.commands.map(dirs => dirs.command.enable ? "`" + dirs.name + "`" : "||" + dirs.name + "||").join(", ")) - .replace("%s3", (prefix + module.exports.command.usage)) - .replace("%s4", ("/" + module.exports.command.usage)) + .replace("%s3", ("/" + module.exports.command.usage)) ) .setColor(clientColor) .setTimestamp() - .setFooter({ "text": "ข้อมูลของเมื่อ" }); + .setFooter({ "text": interaction.client.translate.commands.setCommand.data_at }); return interaction.editReply({ "embeds": [noInputEmbed] }); } diff --git a/source/commands/settings/setLanguage.js b/source/commands/settings/setLanguage.js index 148d3584..39f1198f 100644 --- a/source/commands/settings/setLanguage.js +++ b/source/commands/settings/setLanguage.js @@ -2,72 +2,21 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { getDatabase, ref, child, update } = require("firebase/database"); module.exports = { + "enable": true, "name": "setLanguage", "description": "Sets language for the bot.", "category": "settings", "permissions": { "user": [PermissionsBitField.Flags.ManageGuild], "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "setLanguage [option: set] <value>", - "aliases": ["setlanguage", "lang", "ภาษา"], - async execute(client, message, args) { - const input = args.join(" "); - const inputOption = args[0] ? args[0].toLowerCase() : ""; - const inputValue = args[1] ? args[1].toLowerCase() : ""; - - const guildID = message.guild.id; - const prefix = client.config.prefix; - const lang = client.config.language.code; - const support = client.config.language.support; - const languageRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "language"); - - if (!input) { - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const noInputEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.setLanguage.title) - .setDescription( - client.translate.commands.setLanguage.description - .replace("%s1", support[lang]) - .replace("%s2", (prefix + module.exports.command.usage)) - .replace("%s3", ("/" + module.exports.command.usage)) - ) - .setColor(clientColor) - .setTimestamp() - .setFooter({ "text": client.translate.commands.setLanguage.data_at }) - - return message.channel.send({ "embeds": [noInputEmbed] }); - } - - switch (inputOption) { - case "set": - if (!inputValue) return message.reply(client.translate.commands.setLanguage.empty_value); - if (inputValue === lang) return message.reply(client.translate.commands.setLanguage.already_set.replace("%s", support[inputValue])); - if (!Array.from(Object.keys(support)).includes(inputValue)) return message.reply(client.translate.commands.setLanguage.language_not_support.replace("%s1", inputValue).replace("%s2", Object.keys(support))); - - client.config.language.code = inputValue; - client.translate = require("../../languages/" + inputValue + ".json"); - - set(languageRef, inputValue).then(() => { - message.channel.send(client.translate.commands.setLanguage.set_success.replace("%s", support[inputValue])); - }); - break; - default: - return message.reply(client.translate.commands.setLanguage.invalid_options.replace("%s", inputOption)); - } + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -139,7 +88,6 @@ module.exports.interaction.slash = { const inputValue = interaction.options.get("value"); const guildID = interaction.guild.id; - const prefix = interaction.client.config.prefix; const lang = interaction.client.config.language.code; const support = interaction.client.config.language.support; const languageRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "language"); @@ -152,8 +100,7 @@ module.exports.interaction.slash = { .setDescription( interaction.client.translate.commands.setLanguage.description .replace("%s1", support[lang]) - .replace("%s2", (prefix + module.exports.command.usage)) - .replace("%s3", ("/" + module.exports.command.usage)) + .replace("%s2", ("/" + module.exports.command.usage)) ) .setColor(clientColor) .setTimestamp() diff --git a/source/commands/settings/setNotify.js b/source/commands/settings/setNotify.js index 204c531c..4f187ec1 100644 --- a/source/commands/settings/setNotify.js +++ b/source/commands/settings/setNotify.js @@ -1,214 +1,22 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { getDatabase, ref, child, set } = require("firebase/database"); -const type = [ - "alert", - "channelCreate", - "channelDelete", - "channelPinsUpdate", - "channelUpdate", - "emojiCreate", - "emojiDelete", - "emojiUpdate", - "guildBanAdd", - "guildBanRemove", - "guildIntegrationsUpdate", - "guildMemberAdd", - "guildMemberRemove", - "guildMembersChunk", - "guildUnavailable", - "inviteCreate", - "inviteDelete", - "roleCreate", - "roleDelete", - "roleUpdate", - "stageInstanceCreate", - "stageInstanceDelete", - "stageInstanceUpdate", - "stickerCreate", - "stickerDelete", - "stickerUpdate", - "threadCreate", - "threadDelete", - "threadUpdate", - "webhookUpdate" -]; - module.exports = { + "enable": true, "name": "setNotify", "description": "Set up the notifications you want.", "category": "settings", "permissions": { "user": [PermissionsBitField.Flags.ManageGuild], "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "setNotify [option: set, remove] <type> <channel>", - "aliases": ["setnotify", "notification", "การแจ้งเตือน"], - async execute(client, message, args) { - const input = args.join(" "); - const inputType = args[0]; - const inputOption = args[1] ? args[1].toLowerCase() : ""; - const inputChannel = args[2]; - - const guildID = message.guild.id; - const prefix = client.config.prefix; - const notifyRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "notification"); - const notifySnapshot = client.api.guilds[guildID].notification; - - if (notifySnapshot) { - const alert = notifySnapshot.alert; - const channelCreate = notifySnapshot.channelCreate; - const channelDelete = notifySnapshot.channelDelete; - const channelPinsUpdate = notifySnapshot.channelPinsUpdate; - const channelUpdate = notifySnapshot.channelUpdate; - const emojiCreate = notifySnapshot.emojiCreate; - const emojiDelete = notifySnapshot.emojiDelete; - const emojiUpdate = notifySnapshot.emojiUpdate; - const guildBanAdd = notifySnapshot.guildBanAdd; - const guildBanRemove = notifySnapshot.guildBanRemove; - const guildIntegrationsUpdate = notifySnapshot.guildIntegrationsUpdate; - const guildMemberAdd = notifySnapshot.guildMemberAdd; - const guildMemberRemove = notifySnapshot.guildMemberRemove; - const guildMembersChunk = notifySnapshot.guildMembersChunk; - const guildUnavailable = notifySnapshot.guildUnavailable; - const inviteCreate = notifySnapshot.inviteCreate; - const inviteDelete = notifySnapshot.inviteDelete; - const roleCreate = notifySnapshot.roleCreate; - const roleDelete = notifySnapshot.roleDelete; - const roleUpdate = notifySnapshot.roleUpdate; - const stageInstanceCreate = notifySnapshot.stageInstanceCreate; - const stageInstanceDelete = notifySnapshot.stageInstanceDelete; - const stageInstanceUpdate = notifySnapshot.stageInstanceUpdate; - const stickerCreate = notifySnapshot.stickerCreate; - const stickerDelete = notifySnapshot.stickerDelete; - const stickerUpdate = notifySnapshot.stickerUpdate; - const threadCreate = notifySnapshot.threadCreate; - const threadDelete = notifySnapshot.threadDelete; - const threadUpdate = notifySnapshot.threadUpdate; - const webhookUpdate = notifySnapshot.webhookUpdate; - - if (!input) { - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const noInputEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.setNotify.title) - .setDescription( - client.translate.commands.setNotify.description - .replace("%s1", (alert ? ("<#" + alert + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s2", (channelCreate ? ("<#" + channelCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s3", (channelDelete ? ("<#" + channelDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s4", (channelPinsUpdate ? ("<#" + channelPinsUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s5", (channelUpdate ? ("<#" + channelUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s6", (emojiCreate ? ("<#" + emojiCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s7", (emojiDelete ? ("<#" + emojiDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s8", (emojiUpdate ? ("<#" + emojiUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s9", (guildBanAdd ? ("<#" + guildBanAdd + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s10", (guildBanRemove ? ("<#" + guildBanRemove + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s11", (guildIntegrationsUpdate ? ("<#" + guildIntegrationsUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s12", (guildMemberAdd ? ("<#" + guildMemberAdd + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s13", (guildMemberRemove ? ("<#" + guildMemberRemove + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s14", (guildMembersChunk ? ("<#" + guildMembersChunk + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s15", (guildUnavailable ? ("<#" + guildUnavailable + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s16", (inviteCreate ? ("<#" + inviteCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s17", (inviteDelete ? ("<#" + inviteDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s18", (roleCreate ? ("<#" + roleCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s19", (roleDelete ? ("<#" + roleDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s20", (roleUpdate ? ("<#" + roleUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s21", (stageInstanceCreate ? ("<#" + stageInstanceCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s22", (stageInstanceDelete ? ("<#" + stageInstanceDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s23", (stageInstanceUpdate ? ("<#" + stageInstanceUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s24", (stickerCreate ? ("<#" + stickerCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s25", (stickerDelete ? ("<#" + stickerDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s26", (stickerUpdate ? ("<#" + stickerUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s27", (threadCreate ? ("<#" + threadCreate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s28", (threadDelete ? ("<#" + threadDelete + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s29", (threadUpdate ? ("<#" + threadUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s30", (webhookUpdate ? ("<#" + webhookUpdate + ">") : client.translate.commands.setNotify.not_set)) - .replace("%s31", (prefix + module.exports.command.usage)) - .replace("%s32", ("/" + module.exports.command.usage)) - ) - .setColor(clientColor) - .setTimestamp() - .setFooter({ "text": client.translate.commands.setNotify.data_at }); - - return message.channel.send({ - "embeds": [noInputEmbed] - }); - } - - switch (inputOption) { - case "set": - if (!inputType) return message.reply(client.translate.commands.setNotify.empty_type.replace("%s", type.join(", "))); - if (!type.includes(inputType)) return message.reply(client.translate.commands.setNotify.type_not_found.replace("%s", type.join(", "))); - if (!inputChannel) return message.reply(client.translate.commands.setNotify.empty_config_channel); - - const channel = message.guild.channels.cache.find(channels => (channels.id === inputChannel) || (channels.name === inputChannel)); - - if (!channel) return message.reply(client.translate.commands.setNotify.channel_not_found); - - set(child(notifyRef, inputType), channel.id.toString()).then(() => { - message.channel.send(client.translate.commands.setNotify.set_success.replace("%s1", inputType).replace("%s2", channel.id)); - }); - break; - case "remove": - if (!inputType) return message.reply(client.translate.commands.setNotify.empty_type.replace("%s", type.join(", "))); - if (!type.includes(inputType)) return message.reply(client.translate.commands.setNotify.type_not_found.replace("%s", type.join(", "))); - - set(child(notifyRef, inputType), false).then(() => { - message.channel.send(client.translate.commands.setNotify.remove_success.replace("%s", inputType)); - }); - break; - default: - return message.reply(client.translate.commands.setNotify.invalid_options.replace("%s", inputOption)); - } - } else { - set(notifyRef, { - "alert": false, - "channelCreate": false, - "channelDelete": false, - "channelPinsUpdate": false, - "channelUpdate": false, - "emojiCreate": false, - "emojiDelete": false, - "emojiUpdate": false, - "guildBanAdd": false, - "guildBanRemove": false, - "guildIntegrationsUpdate": false, - "guildMemberAdd": false, - "guildMemberRemove": false, - "guildMembersChunk": false, - "guildUnavailable": false, - "inviteCreate": false, - "inviteDelete": false, - "roleCreate": false, - "roleDelete": false, - "roleUpdate": false, - "stageInstanceCreate": false, - "stageInstanceDelete": false, - "stageInstanceUpdate": false, - "stickerCreate": false, - "stickerDelete": false, - "stickerUpdate": false, - "threadCreate": false, - "threadDelete": false, - "threadUpdate": false, - "webhookUpdate": false - }).then(() => { - module.exports.run(client, message, args); - }); - } + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -313,9 +121,40 @@ module.exports.interaction.slash = { const inputChannel = interaction.options.get("channel"); const guildID = interaction.guild.id; - const prefix = interaction.client.config.prefix; const notifyRef = child(child(ref(getDatabase(), "projects/shioru/guilds"), guildID), "notification"); const notifySnapshot = interaction.client.api.guilds[guildID].notification; + const type = [ + "alert", + "channelCreate", + "channelDelete", + "channelPinsUpdate", + "channelUpdate", + "emojiCreate", + "emojiDelete", + "emojiUpdate", + "guildBanAdd", + "guildBanRemove", + "guildIntegrationsUpdate", + "guildMemberAdd", + "guildMemberRemove", + "guildMembersChunk", + "guildUnavailable", + "inviteCreate", + "inviteDelete", + "roleCreate", + "roleDelete", + "roleUpdate", + "stageInstanceCreate", + "stageInstanceDelete", + "stageInstanceUpdate", + "stickerCreate", + "stickerDelete", + "stickerUpdate", + "threadCreate", + "threadDelete", + "threadUpdate", + "webhookUpdate" + ]; if (notifySnapshot) { const alert = notifySnapshot.alert; @@ -386,8 +225,7 @@ module.exports.interaction.slash = { .replace("%s28", (threadDelete ? ("<#" + threadDelete + ">") : interaction.client.translate.commands.setNotify.not_set)) .replace("%s29", (threadUpdate ? ("<#" + threadUpdate + ">") : interaction.client.translate.commands.setNotify.not_set)) .replace("%s30", (webhookUpdate ? ("<#" + webhookUpdate + ">") : interaction.client.translate.commands.setNotify.not_set)) - .replace("%s31", (prefix + module.exports.command.usage)) - .replace("%s32", ("/" + module.exports.command.usage)) + .replace("%s31", ("/" + module.exports.command.usage)) ) .setColor(clientColor) .setTimestamp() diff --git a/source/commands/settings/setPersonal.js b/source/commands/settings/setPersonal.js index 20c97025..fe75e357 100644 --- a/source/commands/settings/setPersonal.js +++ b/source/commands/settings/setPersonal.js @@ -2,90 +2,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); const { getDatabase, ref, child, set } = require("firebase/database"); module.exports = { + "enable": true, "name": "setPersonal", "description": "Set up about your information.", "category": "settings", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -} - -module.exports.command = { - "enable": true, + }, "usage": "setPersonal [type: avatar, info, uid] <boolean>", - "aliases": ["setpersonal", "pers", "ส่วนตัว", "ข้อมูลส่วนตัว"], - async execute(client, message, args) { - const input = args.join(" "); - const inputType = args[0] ? args[0].toLowerCase() : ""; - const inputBoolean = args[1] ? args[1].toLowerCase() : ""; - - const authorID = message.author.id; - const prefix = client.config.prefix; - const type = ["avatar", "info", "uid"] - const accessRef = child(child(ref(getDatabase(), "projects/shioru/users"), authorID), "access"); - const accessSnapshot = client.api.users[authorID].access; - - if (accessSnapshot) { - const avatar = accessSnapshot.avatar; - const info = accessSnapshot.info; - const uid = accessSnapshot.uid; - - if (!input) { - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const noInputEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.setPersonal.title) - .setDescription( - client.translate.commands.setPersonal.description - .replace("%s1", (avatar ? client.translate.commands.setPersonal.yes : client.translate.commands.setPersonal.no)) - .replace("%s2", (info ? client.translate.commands.setPersonal.yes : client.translate.commands.setPersonal.no)) - .replace("%s3", (uid ? client.translate.commands.setPersonal.yes : client.translate.commands.setPersonal.no)) - .replace("%s4", (prefix + module.exports.command.usage)) - .replace("%s5", ("/" + module.exports.command.usage)) - ) - .setColor(clientColor) - .setTimestamp() - .setFooter({ "text": client.translate.commands.setPersonal.data_at }); - - return message.channel.send({ - "embeds": [noInputEmbed] - }); - } - if (!inputType) return message.reply(client.translate.commands.setPersonal.empty_type.replace("%s", type.join(", "))); - if (!type.includes(inputType)) return message.reply(client.translate.commands.setPersonal.type_not_found.replace("%s", type.join(", "))); - if (!inputBoolean) return message.reply(client.translate.commands.setPersonal.empty_value); - - switch (inputBoolean) { - case "true": - set(child(accessRef, inputType), true).then(() => { - message.channel.send(client.translate.commands.setPersonal.true_success.replace("%s", inputType)); - }); - break; - case "false": - set(child(accessRef, inputType), false).then(() => { - message.channel.send(client.translate.commands.setPersonal.false_success.replace("%s", inputType)); - }); - break; - default: - return message.reply(client.translate.commands.setPersonal.invalid_value); - } - } else { - set(accessRef, { - "avatar": false, - "info": false, - "uid": false - }).then(() => { - module.exports.run(client, message, args); - }); - } + "function": { + "command": {} } } -module.exports.interaction = { - "enable": true -} - -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name.toLowerCase(), "name_localizations": { @@ -179,7 +109,6 @@ module.exports.interaction.slash = { const inputBoolean = interaction.options.get("boolean").value; const authorID = interaction.author.id; - const prefix = interaction.client.config.prefix; const accessRef = child(child(ref(getDatabase(), "projects/shioru/users"), authorID), "access"); const accessSnapshot = interaction.client.api.users[authorID].access; @@ -198,8 +127,7 @@ module.exports.interaction.slash = { .replace("%s1", (avatar ? interaction.client.translate.commands.setPersonal.yes : interaction.client.translate.commands.setPersonal.no)) .replace("%s2", (info ? interaction.client.translate.commands.setPersonal.yes : interaction.client.translate.commands.setPersonal.no)) .replace("%s3", (uid ? interaction.client.translate.commands.setPersonal.yes : interaction.client.translate.commands.setPersonal.no)) - .replace("%s4", (prefix + module.exports.command.usage)) - .replace("%s5", ("/" + module.exports.command.usage)) + .replace("%s4", ("/" + module.exports.command.usage)) ) .setColor(clientColor) .setTimestamp() @@ -224,9 +152,9 @@ module.exports.interaction.slash = { } } else { set(accessRef, { - "avatar": false, - "info": false, - "uid": false + "avatar": true, + "info": true, + "uid": true }).then(() => { module.exports.interaction.execute(interaction); }); diff --git a/source/commands/settings/settings.js b/source/commands/settings/settings.js index e2aa79f5..25a9334d 100644 --- a/source/commands/settings/settings.js +++ b/source/commands/settings/settings.js @@ -1,61 +1,20 @@ const { EmbedBuilder, PermissionsBitField } = require("discord.js"); module.exports = { + "enable": true, "name": "settings", "description": "See how to configure for each settings.", "category": "settings", "permissions": { "client": [PermissionsBitField.Flags.SendMessages] - } -}; - -module.exports.command = { - "enable": true, + }, "usage": "settings", - "aliases": ["config", "cf", "set", "ตั้งค่า", "การตั้งค่า"], - async execute(client, message, args) { - const prefix = client.config.prefix; - const clientFetch = await client.user.fetch(); - const clientColor = clientFetch.accentColor; - const settingsEmbed = new EmbedBuilder() - .setTitle(client.translate.commands.settings.title) - .setDescription(client.translate.commands.settings.description) - .setColor(clientColor) - .setFooter({ "text": client.translate.commands.settings.note, "iconURL": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/microsoft/54/information-source_2139.png" }) - .addFields( - [ - { - "name": client.translate.commands.settings.prefix, - "value": "```" + prefix + "prefix```\n```/prefix```", - "inline": true - }, - { - "name": client.translate.commands.settings.languages, - "value": "```" + prefix + "lang```\n```/lang```", - "inline": true - }, - { - "name": client.translate.commands.settings.notification, - "value": "```" + prefix + "notify```\n```/notify```", - "inline": true - }, - { - "name": client.translate.commands.settings.personal, - "value": "```" + prefix + "personal```\n```/personal```", - "inline": true - } - ] - ); - - message.channel.send({ "embeds": [settingsEmbed] }); + "function": { + "command": {} } -} - -module.exports.interaction = { - "enable": true -} +}; -module.exports.interaction.slash = { +module.exports.function.command = { "data": { "name": module.exports.name, "name_localizations": { @@ -69,7 +28,6 @@ module.exports.interaction.slash = { } }, async execute(interaction) { - const prefix = interaction.client.config.prefix; const clientFetch = await interaction.client.user.fetch(); const clientColor = clientFetch.accentColor; const settingsEmbed = new EmbedBuilder() @@ -81,22 +39,22 @@ module.exports.interaction.slash = { [ { "name": interaction.client.translate.commands.settings.prefix, - "value": "```" + prefix + "prefix```\n```/prefix```", + "value": "```/prefix```", "inline": true }, { "name": interaction.client.translate.commands.settings.languages, - "value": "```" + prefix + "lang```\n```/lang```", + "value": "```/lang```", "inline": true }, { "name": interaction.client.translate.commands.settings.notification, - "value": "```" + prefix + "notify```\n```/notify```", + "value": "```/notify```", "inline": true }, { "name": interaction.client.translate.commands.settings.personal, - "value": "```" + prefix + "personal```\n```/personal```", + "value": "```/personal```", "inline": true } ]