Skip to content

Commit f2d4a03

Browse files
committed
feat: subcommands theory + info command
1 parent e249c16 commit f2d4a03

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

commands/utility/info.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const { SlashCommandBuilder } = require('discord.js');
2+
3+
module.exports = {
4+
category: 'utility',
5+
data: new SlashCommandBuilder()
6+
.setName('info')
7+
.setDescription('Get info about a user or a server!')
8+
.addSubcommand(subcommand =>
9+
subcommand
10+
.setName('user')
11+
.setDescription('Info about a user')
12+
// User object is a mention
13+
.addUserOption(option => option.setName('target').setDescription('The user')))
14+
.addSubcommand(subcommand =>
15+
subcommand
16+
.setName('server')
17+
.setDescription('Info about the server')),
18+
19+
20+
async execute(interaction) {
21+
const subcommand = interaction.options.getSubcommand();
22+
if (subcommand === 'user') {
23+
const user = interaction.options.getUser('target');
24+
if (user) {
25+
await interaction.reply(`Username: ${user.username}\nID: ${user.id}`);
26+
} else {
27+
await interaction.reply('User not found!');
28+
}
29+
} else if (subcommand === 'server') {
30+
await interaction.reply(`Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}`);
31+
}
32+
},
33+
};

0 commit comments

Comments
 (0)