110 lines
3.0 KiB
JavaScript
110 lines
3.0 KiB
JavaScript
const tenor = require('tenorjs').client({
|
|
'Key': process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
|
|
'Filter': 'off', // "off", "low", "medium", "high", not case sensitive
|
|
'Locale': 'en_US',
|
|
'MediaFilter': 'minimal',
|
|
'DateFormat': 'D/MM/YYYY - H:mm:ss A',
|
|
});
|
|
|
|
const { SlashCommandBuilder } = require('@discordjs/builders');
|
|
const { MessageActionRow, MessageButton } = require('discord.js');
|
|
const { GifData, PastaData } = require('../CustomModules/NodBot');
|
|
const fn = require('../functions.js');
|
|
const strings = require('../strings.json');
|
|
const { emoji } = strings;
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('edit')
|
|
.setDescription('Edit content in Nodbot\'s database.')
|
|
// GIF
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('gif')
|
|
.setDescription('Edit a GIF URL')
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('name')
|
|
.setDescription('The name of the GIF to edit')
|
|
.setRequired(true)
|
|
.setAutocomplete(true)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('url')
|
|
.setDescription('The new URL')
|
|
.setRequired(true)
|
|
)
|
|
)
|
|
// Pasta
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('pasta')
|
|
.setDescription('Edit a copypasta\'s content')
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('name')
|
|
.setDescription('The name of the copypasta')
|
|
.setRequired(true)
|
|
.setAutocomplete(true)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('content')
|
|
.setDescription('The new content of the copypasta')
|
|
.setRequired(true)
|
|
)
|
|
),
|
|
async execute(interaction) {
|
|
await interaction.deferReply({ ephemeral: true });
|
|
try {
|
|
// Code Here...
|
|
const subcommand = interaction.options.getSubcommand();
|
|
switch (subcommand) {
|
|
// GIF
|
|
case "gif":
|
|
//TODO
|
|
await this.editGif(interaction, interaction.options.getString('name'), interaction.options.getString('url'));
|
|
break;
|
|
// Joint
|
|
case "joint":
|
|
//TODO
|
|
break;
|
|
// MD
|
|
case "md":
|
|
//TODO
|
|
break;
|
|
// Pasta
|
|
case "pasta":
|
|
//TODO
|
|
await this.editPasta(interaction, interaction.options.getString('name'), interaction.options.getString('content'));
|
|
break;
|
|
// Strain
|
|
case "strain":
|
|
//TODO
|
|
break;
|
|
break;
|
|
// Default
|
|
default:
|
|
|
|
break;
|
|
}
|
|
} catch (err) {
|
|
const errorId = fn.generateErrorId();
|
|
console.error(`${errorId}: err`);
|
|
await interaction.editReply(`Sorry, an error has occured. Error ID: ${errorId}`);
|
|
}
|
|
},
|
|
async editGif(interaction, name, url) {
|
|
const gifData = new GifData().setInfo(name, url);
|
|
await fn.upload.gif(gifData, interaction.client);
|
|
await fn.download.gifs(interaction.client);
|
|
await interaction.editReply(`I've updated ${gifData.name}.gif`);
|
|
},
|
|
async editPasta(interaction, name, content) {
|
|
const pastaData = new PastaData().setInfo(name, content);
|
|
await fn.upload.pasta(pastaData, interaction.client);
|
|
await fn.download.gifs(interaction.client);
|
|
await interaction.editReply(`I've updated ${name}.pasta`);
|
|
}
|
|
}; |