mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-13 12:06:06 -05:00
slash commands integrated
* sample env and late version incr * added slash command compatibility * updated command name * updated environment sample * updated interaction comment
This commit is contained in:
22
src/utils/commands.ts
Normal file
22
src/utils/commands.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { CommandInteraction, ChatInputApplicationCommandData, Client } from 'discord.js'
|
||||
|
||||
/**
|
||||
* interface for how slash commands should be run
|
||||
*/
|
||||
export interface SlashCommand extends ChatInputApplicationCommandData {
|
||||
run: (client: Client, interaction: CommandInteraction) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* register the command to discord for the channel
|
||||
* @param client the bot reference
|
||||
* @param commands commands to register to the bot
|
||||
*/
|
||||
export function registerCommands(client: Client, commands: SlashCommand[]): void {
|
||||
// ensure the bot is online before registering
|
||||
if (!client.application) return
|
||||
|
||||
// iterate through all commands and register them with the bot
|
||||
for (const command of commands)
|
||||
client.application.commands.create(command)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export interface EventProps {
|
||||
tokens: {
|
||||
channel: string,
|
||||
model: string,
|
||||
botUid: string
|
||||
clientUid: string
|
||||
}
|
||||
}
|
||||
export type EventCallback<T extends EventKeys> = (
|
||||
@@ -39,7 +39,7 @@ export function registerEvents(
|
||||
tokens: {
|
||||
channel: string,
|
||||
model: string,
|
||||
botUid: string
|
||||
clientUid: string
|
||||
}
|
||||
): void {
|
||||
for (const { key, callback } of events) {
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
export * from './env.js'
|
||||
export * from './events.js'
|
||||
export * from './messageEmbed.js'
|
||||
export * from './messageNormal.js'
|
||||
export * from './messageNormal.js'
|
||||
export * from './commands.js'
|
||||
Reference in New Issue
Block a user