Ashachor
Ashachor
SIASapphire - Imagine a framework
Created by Ashachor on 6/30/2024 in #sapphire-support
Slash command registered, but not displaying.
I've got a test slash command that is getting registered, but not displaying in Discord.
import {Command, container} from "@sapphire/framework";

class Test extends Command {
constructor(context, options) {
super(context, {
...options,
name: 'test',
description: 'A test command'
});
}

async chatInputRun(interaction, context) {
const repo = container.EventRepository;
const guild_id = interaction.guildId.toString();
let event = await repo.findOneByGuild(guild_id);

const team = event.snakes_and_ladders.getTeam(interaction.options.getString('team', true));

return interaction.reply({
content: `You ran a test command with team ${team.name}`
});
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption(option =>
option
.setName('team')
.setDescription('A team name')
.setRequired(true)
.setAutocomplete(true)
)
);
}
}

export {Test}
import {Command, container} from "@sapphire/framework";

class Test extends Command {
constructor(context, options) {
super(context, {
...options,
name: 'test',
description: 'A test command'
});
}

async chatInputRun(interaction, context) {
const repo = container.EventRepository;
const guild_id = interaction.guildId.toString();
let event = await repo.findOneByGuild(guild_id);

const team = event.snakes_and_ladders.getTeam(interaction.options.getString('team', true));

return interaction.reply({
content: `You ran a test command with team ${team.name}`
});
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand(builder =>
builder
.setName(this.name)
.setDescription(this.description)
.addStringOption(option =>
option
.setName('team')
.setDescription('A team name')
.setRequired(true)
.setAutocomplete(true)
)
);
}
}

export {Test}
12 replies
SIASapphire - Imagine a framework
Created by Ashachor on 6/28/2024 in #sapphire-support
Slash Command - The application did not respond - nothing in console.
I've set up a slash command, it appears in discord, but when I run it I get "The application did not respond". The application log doesn't show any activity. This is a shortened version of my command.
import {Command, container} from "@sapphire/framework";
import {ChannelType} from "discord-api-types/v10";

class SalCommand extends Command {
constructor(context, options) {
super(context, {
...options,
name: 'sal',
subcommands: [
{
name: 'create-event',
chatInputRun: 'chatInputCreateEvent'
},
]
});
}

async chatInputCreateEvent(interaction, context) {
console.info('Creating Event');
const name = 'Event Name';
return interaction.reply({
content: `Your event, ${name}, has been created`
})
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName(this.name)
.setDescription('The root command')
.addSubcommand((builder) =>
builder
.setName('create-event')
.setDescription('Create a new Snakes and Ladders event')
.addChannelOption((option) =>
option
.setName('watch-channel')
.setDescription('The channel to watch for drops')
.setRequired(true)
.addChannelTypes(ChannelType.GuildText)
)
.addChannelOption((option) =>
option
.setName('message-channel')
.setDescription('The channel where update messages should be sent')
.setRequired(true)
.addChannelTypes(ChannelType.GuildText)
)
.addStringOption((option) =>
option
.setName('event-json')
.setDescription('The json representing the event')
.setRequired(true)
)
)
)
}
}

export {SalCommand};
import {Command, container} from "@sapphire/framework";
import {ChannelType} from "discord-api-types/v10";

class SalCommand extends Command {
constructor(context, options) {
super(context, {
...options,
name: 'sal',
subcommands: [
{
name: 'create-event',
chatInputRun: 'chatInputCreateEvent'
},
]
});
}

async chatInputCreateEvent(interaction, context) {
console.info('Creating Event');
const name = 'Event Name';
return interaction.reply({
content: `Your event, ${name}, has been created`
})
}

registerApplicationCommands(registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName(this.name)
.setDescription('The root command')
.addSubcommand((builder) =>
builder
.setName('create-event')
.setDescription('Create a new Snakes and Ladders event')
.addChannelOption((option) =>
option
.setName('watch-channel')
.setDescription('The channel to watch for drops')
.setRequired(true)
.addChannelTypes(ChannelType.GuildText)
)
.addChannelOption((option) =>
option
.setName('message-channel')
.setDescription('The channel where update messages should be sent')
.setRequired(true)
.addChannelTypes(ChannelType.GuildText)
)
.addStringOption((option) =>
option
.setName('event-json')
.setDescription('The json representing the event')
.setRequired(true)
)
)
)
}
}

export {SalCommand};
6 replies