Skip to content

Commit

Permalink
fixed help menu and update discord.js
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Apr 11, 2024
1 parent df1526c commit 8993e1e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"chalk": "^5.0.1",
"dayjs": "^1.11.3",
"dirname-filename-esm": "^1.1.1",
"discord.js": "^14.13.0",
"discord.js": "^14.14.1",
"dotenv": "^16.0.1",
"figlet": "^1.5.2",
"ghom-eval": "^1.1.3",
Expand Down
9 changes: 7 additions & 2 deletions src/app/slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface ISlashCommandInteraction
discord.CommandInteraction,
"guild" | "guildId" | "channel" | "options"
> {
base: discord.CommandInteraction
guild?: discord.Guild
guildId?: string
channel:
Expand All @@ -146,6 +147,9 @@ export interface SlashCommandInteraction<
discord.CommandInteraction,
"guild" | "guildId" | "channel" | "options"
> {
base: GuildOnly extends true
? discord.CommandInteraction<"raw" | "cached">
: discord.CommandInteraction
guild: GuildOnly extends true ? discord.Guild : undefined
guildId: GuildOnly extends true ? string : undefined
channel: ChannelType extends "dm"
Expand Down Expand Up @@ -276,11 +280,12 @@ export async function registerSlashCommands(guildId?: string) {
}

export async function prepareSlashCommand(
interaction: discord.CommandInteraction | ISlashCommandInteraction,
interaction: discord.CommandInteraction,
command: ISlashCommand,
): Promise<ISlashCommandInteraction | discord.EmbedBuilder> {
// @ts-ignore
const output: ISlashCommandInteraction = {
base: interaction,
...interaction,
guild: undefined,
guildId: undefined,
Expand All @@ -301,7 +306,7 @@ export async function prepareSlashCommand(
(command.options.guildOnly !== false &&
command.options.channelType !== "dm")
) {
if (!interaction.inGuild?.() || !interaction.guild)
if (!interaction.inGuild() || !interaction.guild)
return new discord.EmbedBuilder()
.setColor("Red")
.setDescription("This command can only be used in a guild")
Expand Down
5 changes: 4 additions & 1 deletion src/slash/help.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default new app.SlashCommand({
(
await Promise.all(
app.slashCommands.map(async (cmd) => {
const prepared = await app.prepareSlashCommand(interaction, cmd)
const prepared = await app.prepareSlashCommand(
interaction.base,
cmd,
)

if (prepared instanceof app.EmbedBuilder) return ""

Expand Down

0 comments on commit 8993e1e

Please sign in to comment.