Skylar Grant
663c8e0a1a
All checks were successful
NodBot Production Dockerization / build (pull_request) Successful in 15s
173 lines
4.8 KiB
JavaScript
173 lines
4.8 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, StrainData } = 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)
|
|
)
|
|
)
|
|
// Strain
|
|
.addSubcommand(subcommand =>
|
|
subcommand
|
|
.setName('strain')
|
|
.setDescription('Edit a strain\'s data')
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('name')
|
|
.setDescription('Name of the strain')
|
|
.setRequired(true)
|
|
.setAutocomplete(true)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('type')
|
|
.setDescription('Indica/Sativa/Hybrid')
|
|
.setRequired(false)
|
|
.addChoices(
|
|
{ name: "Indica", value: "Indica" },
|
|
{ name: "Hybrid", value: "Hybrid" },
|
|
{ name: "Sativa", value: "Sativa" }
|
|
)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('effects')
|
|
.setDescription('What effects does the strain produce?')
|
|
.setRequired(false)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('flavor')
|
|
.setDescription('Flavor Profile')
|
|
.setRequired(false)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('rating')
|
|
.setDescription('Star rating of the strain on Leaf.ly')
|
|
.setRequired(false)
|
|
)
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('description')
|
|
.setDescription('Summary of the strain')
|
|
.setRequired(false)
|
|
)
|
|
),
|
|
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
|
|
await this.editStrain(interaction);
|
|
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`);
|
|
},
|
|
async editStrain(interaction) {
|
|
const details = {
|
|
type: interaction.options.getString('type'),
|
|
effects: interaction.options.getString('effects'),
|
|
flavor: interaction.options.getString('flavor'),
|
|
rating: interaction.options.getString('rating'),
|
|
description: interaction.options.getString('description')
|
|
};
|
|
const strainData = interaction.client.strains.get(interaction.options.getString('name'));
|
|
strainData.setInfo(interaction.options.getString('name'), details);
|
|
await fn.upload.strain(interaction, strainData);
|
|
const reply = await fn.download.strain(strainData.name, interaction);
|
|
await interaction.editReply(reply);
|
|
}
|
|
}; |