Skip to content

Commit 2ecd8fe

Browse files
authored
feat: adding a reping command (#139)
1 parent bf98a20 commit 2ecd8fe

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/commands/reping.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { command } from 'jellycommands';
2+
import { wrap_in_embed } from '../utils/embed_helpers';
3+
import { GuildMemberRoleManager } from 'discord.js';
4+
5+
export default command({
6+
name: 'reping',
7+
description: 'Ping a role',
8+
9+
global: true,
10+
11+
options: [
12+
{
13+
name: 'role',
14+
description: 'The role you want to ping',
15+
type: 'Role',
16+
required: true,
17+
},
18+
],
19+
20+
run: async ({ interaction }) => {
21+
// Find the desired role
22+
const role = interaction.options.getRole('role', true);
23+
// Check if the user has the role
24+
let hasRole = (
25+
interaction.member.roles as GuildMemberRoleManager
26+
).cache.find((val) => val.id === role.id);
27+
// Exit if the user doesn't have the role
28+
if (!hasRole) return;
29+
// Send the ping message
30+
interaction.channel.send(`<@&${role.id}>`);
31+
// Follow up the interaction
32+
await interaction.reply(wrap_in_embed('Role pinged'));
33+
// Delete the reply after 3 seconds
34+
setTimeout(async () => {
35+
await interaction.deleteReply();
36+
}, 3000);
37+
},
38+
});

0 commit comments

Comments
 (0)