Compare commits

...

2 commits

Author SHA1 Message Date
c908a524aa Fix deploy 2022-10-13 16:32:58 +02:00
16ddd8b388 Resolve the user first 2022-10-13 15:55:56 +02:00
2 changed files with 14 additions and 19 deletions

View file

@ -33,7 +33,10 @@ export default {
const body = { type:command, uid: userid, reason: reason };
Blacklists.create(body);
let user = userid;
if (command !== 'guild') {user = client.users.fetch(userid).tag;}
if (command !== 'guild') {
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}`);
}

View file

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