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.
feat(utility): add
spoonfeed
commands
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/components/utility/commands/spoonfeed/chat-input-command.ts
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,31 @@ | ||
import { | ||
ApplicationCommandOptionType, | ||
ApplicationCommandType, | ||
} from '@discordjs/core'; | ||
import { spoonfeedMessage } from './message.js'; | ||
import { ChatInputCommand } from '/components/types.js'; | ||
import { mapChatInputOptionValues } from '/utils/interactions.js'; | ||
|
||
export const spoonfeedCommand = { | ||
data: { | ||
type: ApplicationCommandType.ChatInput, | ||
name: 'spoonfeed', | ||
description: 'Send information about how to learn', | ||
options: [ | ||
{ | ||
type: ApplicationCommandOptionType.Mentionable, | ||
name: 'mention', | ||
description: 'An optional user to mention', | ||
}, | ||
], | ||
}, | ||
async execute({ api, data: interaction }) { | ||
const { mention } = mapChatInputOptionValues(interaction.data) as { | ||
mention: string | undefined; | ||
}; | ||
|
||
await api.interactions.reply(interaction.id, interaction.token, { | ||
content: spoonfeedMessage(mention), | ||
}); | ||
}, | ||
} satisfies ChatInputCommand; |
33 changes: 33 additions & 0 deletions
33
src/components/utility/commands/spoonfeed/message-command.ts
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,33 @@ | ||
import { ApplicationCommandType, MessageFlags } from '@discordjs/core'; | ||
import { messageLink } from '@discordjs/formatters'; | ||
import { spoonfeedMessage } from './message.js'; | ||
import { MessageCommand } from '/components/types.js'; | ||
|
||
export const spoonfeedMessageCommand = { | ||
data: { | ||
type: ApplicationCommandType.Message, | ||
name: 'How to Learn', | ||
}, | ||
guildSpecific: true, | ||
async execute({ api, data: interaction }) { | ||
await api.interactions.defer(interaction.id, interaction.token, { | ||
flags: MessageFlags.Ephemeral, | ||
}); | ||
|
||
const message = await api.channels.createMessage( | ||
interaction.channel.id, | ||
{ | ||
content: spoonfeedMessage(), | ||
message_reference: { message_id: interaction.data.target_id }, | ||
}, | ||
); | ||
|
||
await api.interactions.editReply( | ||
interaction.application_id, | ||
interaction.token, | ||
{ | ||
content: messageLink(message.channel_id, message.id), | ||
}, | ||
); | ||
}, | ||
} satisfies MessageCommand; |
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,35 @@ | ||
import { Snowflake } from '@discordjs/core'; | ||
import { | ||
bold, | ||
hideLinkEmbed, | ||
hyperlink, | ||
unorderedList, | ||
userMention, | ||
} from '@discordjs/formatters'; | ||
|
||
export function spoonfeedMessage(userId?: Snowflake) { | ||
const content = [ | ||
bold('Information will not be spoonfed to you.'), | ||
'You are expected to be able to learn and understand programming concepts.', | ||
'Understand that even if you are "new to this dev stuff", we all started off with no knowledge in the space.', | ||
'Just as we take our time and learn, you are advised to do the same. Here are a few links to help you start:', | ||
unorderedList([ | ||
hyperlink('Lua Docs', hideLinkEmbed('https://lua.org/docs.html')), | ||
hyperlink( | ||
'Programming in Lua e-book', | ||
hideLinkEmbed('https://lua.org/pil/contents.html'), | ||
), | ||
hyperlink( | ||
'FiveM Docs', | ||
hideLinkEmbed('https://docs.fivem.net/docs/'), | ||
), | ||
hyperlink( | ||
'Effective FiveM Lua', | ||
hideLinkEmbed('https://manason.github.io/effective-fivem-lua/'), | ||
), | ||
]), | ||
]; | ||
if (userId) content.unshift(userMention(userId)); | ||
|
||
return content.join('\n'); | ||
} |
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