Compare commits
2 commits
cc25953e90
...
c908a524aa
Author | SHA1 | Date | |
---|---|---|---|
c908a524aa | |||
16ddd8b388 |
2 changed files with 14 additions and 19 deletions
|
@ -33,7 +33,10 @@ 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') {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}`);
|
return interaction.editReply(`${user} has been blacklisted from ${command} with the following reason ${reason}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,20 @@ 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`);
|
||||||
categoryPath.forEach(category => {
|
for (let i = 0; i < categoryPath.length; i++) {
|
||||||
loadCommandFromDir(category);
|
const commandsPath = path.join(`${__dirname}/../commands`, categoryPath[i]);
|
||||||
});
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||||
commands.map(command => command.toJSON());
|
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);
|
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.'))
|
||||||
|
@ -33,15 +37,3 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue