summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/add.js26
-rw-r--r--commands/delete.js17
-rw-r--r--commands/help.js11
-rw-r--r--commands/preview.js16
-rw-r--r--commands/use.js16
5 files changed, 86 insertions, 0 deletions
diff --git a/commands/add.js b/commands/add.js
new file mode 100644
index 0000000..5d74b6a
--- /dev/null
+++ b/commands/add.js
@@ -0,0 +1,26 @@
+const { SlashCommandBuilder } = require('discord.js');
+
+module.exports = {
+ data: new SlashCommandBuilder()
+ .setName('add')
+ .setDescription('Add a Command')
+ .addStringOption(option =>
+ option.setName('command')
+ .setDescription('The name of the command `/use THIS`')
+ .setRequired(true))
+ .addStringOption(option =>
+ option.setName('content')
+ .setDescription('What the bot will send')
+ .setRequired(true)),
+ async execute(interaction) {
+ if (global.data.getList().length <= 25)
+ {
+ global.data.add(interaction.options.getString('command'),interaction.options.getString('content'));
+ await interaction.reply('Added `'+interaction.options.getString('command')+'`.');
+ }
+ else
+ {
+ await interaction.reply('Failed to add command. There is a hard limit of 25 commands!');
+ }
+ },
+}; \ No newline at end of file
diff --git a/commands/delete.js b/commands/delete.js
new file mode 100644
index 0000000..60c541f
--- /dev/null
+++ b/commands/delete.js
@@ -0,0 +1,17 @@
+const { SlashCommandBuilder } = require('discord.js');
+
+module.exports = {
+ data: new SlashCommandBuilder()
+ .setName('remove')
+ .setDescription('Remove a Command')
+ .addStringOption(option =>
+ option.setName('command')
+ .setDescription('Name of the command to remove')
+ .setRequired(true)
+ .setChoices(...global.data.getList())
+ ),
+ async execute(interaction) {
+ global.data.remove(interaction.options.getString('command'))
+ await interaction.reply('Removed `'+interaction.options.getString('command')+'`.');
+ },
+}; \ No newline at end of file
diff --git a/commands/help.js b/commands/help.js
new file mode 100644
index 0000000..92d3e89
--- /dev/null
+++ b/commands/help.js
@@ -0,0 +1,11 @@
+const { SlashCommandBuilder } = require('discord.js');
+const fs = require('fs');
+
+module.exports = {
+ data: new SlashCommandBuilder()
+ .setName('help')
+ .setDescription('Shows the manual'),
+ async execute(interaction) {
+ await interaction.reply({content: fs.readFileSync('help.md', 'utf-8'), ephemeral: true});
+ },
+}; \ No newline at end of file
diff --git a/commands/preview.js b/commands/preview.js
new file mode 100644
index 0000000..013f650
--- /dev/null
+++ b/commands/preview.js
@@ -0,0 +1,16 @@
+const { SlashCommandBuilder } = require('discord.js');
+
+module.exports = {
+ data: new SlashCommandBuilder()
+ .setName('preview')
+ .setDescription('Only you can see this!')
+ .addStringOption(option =>
+ option.setName('command')
+ .setDescription('Name of the command to display')
+ .setRequired(true)
+ .addChoices(...global.data.getList())
+ ),
+ async execute(interaction) {
+ await interaction.reply({content: global.data.get(interaction.options.getString('command')), ephemeral: true});
+ },
+}; \ No newline at end of file
diff --git a/commands/use.js b/commands/use.js
new file mode 100644
index 0000000..dc9897b
--- /dev/null
+++ b/commands/use.js
@@ -0,0 +1,16 @@
+const { SlashCommandBuilder } = require('discord.js');
+
+module.exports = {
+ data: new SlashCommandBuilder()
+ .setName('use')
+ .setDescription('Use a Command')
+ .addStringOption(option =>
+ option.setName('command')
+ .setDescription('What the bot will send')
+ .setRequired(true)
+ .addChoices(...global.data.getList())
+ ),
+ async execute(interaction) {
+ await interaction.reply(global.data.get(interaction.options.getString('command')));
+ },
+}; \ No newline at end of file