aboutsummaryrefslogtreecommitdiff
path: root/bot/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src/commands')
-rw-r--r--bot/src/commands/fetch.js34
-rw-r--r--bot/src/commands/rm.js1
-rw-r--r--bot/src/commands/serverinfo.js3
-rw-r--r--bot/src/commands/settings.js35
-rw-r--r--bot/src/commands/suggest.js1
-rw-r--r--bot/src/commands/userinfo.js1
6 files changed, 57 insertions, 18 deletions
diff --git a/bot/src/commands/fetch.js b/bot/src/commands/fetch.js
new file mode 100644
index 0000000..651fb06
--- /dev/null
+++ b/bot/src/commands/fetch.js
@@ -0,0 +1,34 @@
+import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js';
+
+export default {
+ data: new SlashCommandBuilder()
+ .setName('fetch')
+ .setDescription('Fetches JSON data.')
+ .addStringOption(option =>
+ option
+ .setName('url')
+ .setDescription('Enter the URL you want to fetch.')
+ .setRequired(true)),
+ execute(interaction) {
+ const url = interaction.options.getString('url');
+ fetch(url)
+ .then(response => response.json())
+ .then(async data => {
+ const dataString = JSON.stringify(data, null, 2);
+ if (dataString.length === 0) {
+ return await interaction.reply('Received an empty response.');
+ }
+
+ if (dataString.length > 2000) {
+ const attachment = new AttachmentBuilder(Buffer.from(dataString, 'utf-8'), { name: 'messages.json' });
+ return await interaction.reply({ files: [attachment] });
+ }
+
+ return await interaction.reply(`\`\`\`json\n${dataString}\n\`\`\``);
+ })
+ .catch(async error => {
+ console.error(error);
+ return await interaction.reply(`An error occurred while fetching the URL data.\n\`\`\`js\n${error.stack}\`\`\``);
+ });
+ }
+};
diff --git a/bot/src/commands/rm.js b/bot/src/commands/rm.js
index 9edfdc4..64543ac 100644
--- a/bot/src/commands/rm.js
+++ b/bot/src/commands/rm.js
@@ -4,6 +4,7 @@ export default {
data: new SlashCommandBuilder()
.setName('rm')
.setDescription('Purges messages.')
+ .setContexts(0)
.addNumberOption(option =>
option
.setName('amount')
diff --git a/bot/src/commands/serverinfo.js b/bot/src/commands/serverinfo.js
index 480087d..3f7bd72 100644
--- a/bot/src/commands/serverinfo.js
+++ b/bot/src/commands/serverinfo.js
@@ -4,7 +4,8 @@ import { abEmbedColour } from '../storage/consts.js';
export default {
data: new SlashCommandBuilder()
.setName('serverinfo')
- .setDescription('Information about this server.'),
+ .setDescription('Information about this server.')
+ .setContexts(0),
async execute(interaction) {
// let listedChannels = [];
let guildOwner = await interaction.guild.fetchOwner();
diff --git a/bot/src/commands/settings.js b/bot/src/commands/settings.js
index 88e108d..e5f4ee3 100644
--- a/bot/src/commands/settings.js
+++ b/bot/src/commands/settings.js
@@ -20,13 +20,14 @@ export default {
.addSubcommand(subcommand =>
subcommand
.setName('guild')
- .setDescription('Change settings for the guild.'))
- .addSubcommand(subcommand =>
- subcommand
- .setName('user')
- .setDescription('Change settings for the user.')),
+ .setDescription('Change settings for the guild.')),
+ // .addSubcommand(subcommand =>
+ // subcommand
+ // .setName('user')
+ // .setDescription('Change settings for the user.')),
async execute(interaction) {
if (interaction.options.getSubcommand() === 'guild') {
+ if (!interaction.guild) return await interaction.reply({ content: 'This command can only be run in a guild.' });
//if (!interaction.member.permissions.has(PermissionFlagsBits.ManageGuild)) return await interaction.reply({ content: 'You do not have the permission to manage this guild.', flags: MessageFlags.Ephemeral });
const guildSetting = await guildSettings.findOne({ where: { guildID: interaction.guild.id } });
@@ -126,17 +127,17 @@ export default {
});
}
- if (interaction.options.getSubcommand() === 'user') {
- const userEmbed = new EmbedBuilder()
- .setAuthor({ name: 'AleeBot User Settings', iconURL: interaction.client.user.avatarURL() })
- .setDescription('Select the options')
- .addFields(
- { name: 'Language', value: 'logchannel', inline: true },
- { name: 'Location', value: 'channel', inline: true }
- )
- .setColor(abEmbedColour);
-
- return await interaction.reply({ embeds: [userEmbed] });
- }
+ // if (interaction.options.getSubcommand() === 'user') {
+ // const userEmbed = new EmbedBuilder()
+ // .setAuthor({ name: 'AleeBot User Settings', iconURL: interaction.client.user.avatarURL() })
+ // .setDescription('Select the options')
+ // .addFields(
+ // { name: 'Language', value: 'logchannel', inline: true },
+ // { name: 'Location', value: 'channel', inline: true }
+ // )
+ // .setColor(abEmbedColour);
+ //
+ // return await interaction.reply({ embeds: [userEmbed] });
+ // }
}
};
diff --git a/bot/src/commands/suggest.js b/bot/src/commands/suggest.js
index 7bb91e2..b8fe68a 100644
--- a/bot/src/commands/suggest.js
+++ b/bot/src/commands/suggest.js
@@ -65,6 +65,7 @@ export default {
}
if (interaction.options.getSubcommand() === 'guild') {
+ if (!interaction.guild) return await interaction.reply({ content: 'This command can only be run in a guild.' });
const guildSetting = await guildSettings.findOne({ where: { guildID: interaction.guild.id } });
if (!guildSetting || !guildSetting.suggestionsChannelID) return await interaction.reply({ content: 'This server did not configure to have suggestions enabled.' });
diff --git a/bot/src/commands/userinfo.js b/bot/src/commands/userinfo.js
index 0cf7332..8119a16 100644
--- a/bot/src/commands/userinfo.js
+++ b/bot/src/commands/userinfo.js
@@ -5,6 +5,7 @@ export default {
data: new SlashCommandBuilder()
.setName('userinfo')
.setDescription('Information about a user.')
+ .setContexts(0)
.addUserOption(option =>
option
.setName('username')