generated from D4isDAVID/discord.js-components-bot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
APIInteractionResponseCallbackData, | ||
ApplicationCommandOptionType, | ||
ApplicationCommandType, | ||
MessageFlags, | ||
} from '@discordjs/core'; | ||
import { ChatInputCommand } from '/components/types.js'; | ||
import { mapChatInputOptionValues } from '/utils/interactions.js'; | ||
|
||
const invites: Record<string, string> = { | ||
ox: 'https://discord.overextended.dev/', | ||
'project-error': 'https://discord.gg/uy5N7jT5aJ', | ||
txAdmin: 'https://discord.gg/yWxjt9zPWR', | ||
cfx: 'https://discord.gg/fivem', | ||
}; | ||
|
||
export const guildCommand = { | ||
data: { | ||
type: ApplicationCommandType.ChatInput, | ||
name: 'guild', | ||
description: 'Send an invite link to a server', | ||
options: [ | ||
{ | ||
type: ApplicationCommandOptionType.String, | ||
name: 'name', | ||
description: 'The server name', | ||
required: true, | ||
choices: [ | ||
{ name: 'Overextended', value: 'ox' }, | ||
{ name: 'Project Error', value: 'project-error' }, | ||
{ name: 'txAdmin', value: 'txAdmin' }, | ||
{ name: 'Cfx.re', value: 'cfx' }, | ||
], | ||
}, | ||
], | ||
}, | ||
async execute({ api, data: interaction }) { | ||
const { name: guild } = mapChatInputOptionValues(interaction.data) as { | ||
name: string; | ||
}; | ||
|
||
const invite = invites[guild]; | ||
const message: APIInteractionResponseCallbackData = { | ||
content: invite ?? 'Unknown guild selected.', | ||
}; | ||
if (invite) message.flags = MessageFlags.Ephemeral; | ||
|
||
await api.interactions.reply( | ||
interaction.id, | ||
interaction.token, | ||
message, | ||
); | ||
}, | ||
} satisfies ChatInputCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from '../types.js'; | ||
import { guildCommand } from './commands/guild.js'; | ||
|
||
export default { | ||
commands: [guildCommand], | ||
} satisfies Component; |