Search…
Context menu actions
Add commands to context menus shown on right-click for users and messages
There are 2 types of context menu actions, depending on what the end user is opening the context menu on.
User context
Message context
1
import { Interaction } from 'detritus-client'
2
import { MessageFlags } from 'detritus-client/lib/constants'
3
4
import { BaseContextMenuUserCommand, ContextMenuUserArgs } from '../../base'
5
6
export default class InformationCommand extends BaseContextMenuUserCommand {
7
name = 'Avatar'
8
9
async run (context: Interaction.InteractionContext, args: ContextMenuUserArgs): Promise<void> {
10
await context.editOrRespond({
11
embed: {
12
description: `${args.user.mention}'s avatar`,
13
image: {
14
url: `${args.user.avatarUrl}?size=512`
15
}
16
},
17
flags: MessageFlags.EPHEMERAL
18
})
19
}
20
}
21
Copied!
1
import { Interaction } from 'detritus-client'
2
import { MessageFlags } from 'detritus-client/lib/constants'
3
4
import { BaseContextMenuMessageCommand, ContextMenuMessageArgs } from '../../base'
5
6
export default class InformationCommand extends BaseContextMenuMessageCommand {
7
name = 'Message ID'
8
9
async run (context: Interaction.InteractionContext, args: ContextMenuMessageArgs): Promise<void> {
10
await context.editOrRespond({
11
embed: {
12
description: `Message ID: ${args.message.id}`
13
},
14
flags: MessageFlags.EPHEMERAL
15
})
16
}
17
}
18
Copied!
Export as PDF
Copy link