Skip to content

Commit

Permalink
⚒️ Update to be able to use with the new system
Browse files Browse the repository at this point in the history
  • Loading branch information
Maseshi committed Aug 10, 2022
1 parent 167b16d commit b97f5b7
Show file tree
Hide file tree
Showing 60 changed files with 4,053 additions and 3,615 deletions.
65 changes: 34 additions & 31 deletions source/commands/developer/ping.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
module.exports.run = async (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 { EmbedBuilder } = require("discord.js");

msg.edit({
"content": client.translate.commands.ping.result,
"embeds": [
{
"title": client.translate.commands.ping.connection,
"description": client.translate.commands.ping.info.replace("%s1", ping).replace("%s2", api)
}
]
});
};

module.exports.help = {
module.exports = {
"name": "ping",
"description": "Check the ping and api latency of the bot.",
"usage": "ping",
"category": "developer",
"aliases": ["ปิง", "การเชื่อมต่อ"],
"clientPermissions": ["SEND_MESSAGES"]
"permissions": {
"client": ["SEND_MESSAGES"]
}
};

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]
});
}
}

module.exports.interaction = {
"enable": true,
"data": {
"name": module.exports.help.name,
"name": module.exports.name,
"name_localizations": {
"en-US": "ping",
"th": "ปิง"
},
"description": module.exports.help.description,
"description": module.exports.description,
"description_localizations": {
"en-US": "Check the ping and api latency of the bot.",
"th": "ตรวจสอบความหน่วงและ API Latency ของบอท"
}
},
async execute(interaction) {
await interaction.editReply(interaction.client.translate.commands.ping.waiting);

const ping = Math.round((Date.now() - interaction.createdTimestamp) - interaction.client.ws.ping);
const msg = await interaction.editReply(interaction.client.translate.commands.ping.waiting);
const ping = Math.round((msg.createdTimestamp - interaction.createdTimestamp) - interaction.client.ws.ping);
const api = Math.round(interaction.client.ws.ping);
const pingEmbed = new EmbedBuilder()
.setTitle(interaction.client.translate.commands.ping.connection)
.setDescription(interaction.client.translate.commands.ping.info.replace("%s1", ping).replace("%s2", api))

await interaction.editReply({
"content": interaction.client.translate.commands.ping.result,
"embeds": [
{
"title": interaction.client.translate.commands.ping.connection,
"description": interaction.client.translate.commands.ping.info.replace("%s1", ping).replace("%s2", api)
}
]
"embeds": [pingEmbed]
});
}
};
}
88 changes: 47 additions & 41 deletions source/commands/developer/reload.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
const { readdirSync } = require("node:fs");
const path = require("path");

module.exports.run = (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);
}
}
});
};

module.exports.help = {
module.exports = {
"name": "reload",
"description": "Reload the command that doesn't work.",
"usage": "reload <command: name, aliases>",
"category": "developer",
"permissions": {
"client": ["SEND_MESSAGES"]
}
}

module.exports.command = {
"enable": true,
"usage": "reload <command: name, aliases>",
"aliases": ["recommand", "รีโหลด", "โหลดซ้ำ"],
"clientPermissions": ["SEND_MESSAGES"]
};
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);
}
}
});
}
}

module.exports.interaction = {
"enable": true,
"data": {
"name": module.exports.help.name,
"name": module.exports.name,
"name_localizations": {
"en-US": "reload",
"th": "โหลดซ้ำ"
},
"description": module.exports.help.description,
"description": module.exports.description,
"description_localizations": {
"en-US": "Reload the command that doesn't work.",
"th": "โหลดคำสั่งที่ไม่ทำงานอีกครั้ง"
Expand Down Expand Up @@ -100,4 +106,4 @@ module.exports.interaction = {
}
});
}
}
}
Loading

0 comments on commit b97f5b7

Please sign in to comment.