Compare commits

..

No commits in common. "c908a524aac6e16da1791564389df4c4d5f77dd3" and "cc25953e909de3b72fae61777a9b2f5b964770df" have entirely different histories.

2 changed files with 19 additions and 14 deletions

View file

@ -33,10 +33,7 @@ export default {
const body = { type:command, uid: userid, reason: reason }; const body = { type:command, uid: userid, reason: reason };
Blacklists.create(body); Blacklists.create(body);
let user = userid; let user = userid;
if (command !== 'guild') { if (command !== 'guild') {user = client.users.fetch(userid).tag;}
await client.users.resolve(userid);
user = client.users.fetch(userid).tag;
}
return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason ${reason}`); return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason ${reason}`);
} }

View file

@ -9,20 +9,16 @@ const { clientId, guildId, token } = process.env;
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
const commands = [];
const commands = [];
const categoryPath = fs.readdirSync(`${__dirname}/../commands`); const categoryPath = fs.readdirSync(`${__dirname}/../commands`);
for (let i = 0; i < categoryPath.length; i++) { categoryPath.forEach(category => {
const commandsPath = path.join(`${__dirname}/../commands`, categoryPath[i]); loadCommandFromDir(category);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); });
for (const file of commandFiles) { commands.map(command => command.toJSON());
const filePath = path.join(commandsPath, file);
const command = await import(filePath);
commands.push(command.default.data.toJSON());
}
}
const rest = new REST({ version: '9' }).setToken(token); const rest = new REST({ version: '9' }).setToken(token);
if (process.argv[2] === 'global') { if (process.argv[2] === 'global') {
rest.put(Routes.applicationCommands(clientId), { body: commands }) rest.put(Routes.applicationCommands(clientId), { body: commands })
.then(() => console.log('Successfully registered application commands globally.')) .then(() => console.log('Successfully registered application commands globally.'))
@ -37,3 +33,15 @@ else if (process.argv[2] === 'delete') {
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands }) rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`)) .then(() => console.log(`Successfully registered application commands for the guild ${guildId}.`))
.catch(console.error); .catch(console.error);
async function loadCommandFromDir(dir) {
const commandsPath = path.join(`${__dirname}/../commands`, dir);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
let command = await import(filePath);
command = command.default;
commands.push(command.data);
}
}