Refactor to more consistent structure (e.g. "plugins")
This commit is contained in:
29
plugins/quote/index.ts
Normal file
29
plugins/quote/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type {ChatInputCommandInteraction} from 'discord.js';
|
||||
import {SlashCommandBuilder} from 'discord.js';
|
||||
import {BasePlugin, type Settings } from '../../plugin';
|
||||
import {quotes} from './quotes.json';
|
||||
|
||||
export class QuotePlugin extends BasePlugin {
|
||||
constructor(settings: Settings) {
|
||||
super(settings);
|
||||
this.commands = [
|
||||
{
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('quote')
|
||||
.setDescription('Print a quote from League of Legends.'),
|
||||
|
||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||
try {
|
||||
const index = Math.floor(Math.random() * quotes.length);
|
||||
await interaction.reply?.({
|
||||
content: `> *${quotes[index].quote}*
|
||||
> — ${quotes[index].author}`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Problem sending to channel: ${error}`);
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user