diff --git a/src/discord/commands/guild/d.mushroom_info.ts b/src/discord/commands/guild/d.mushroom_info.ts new file mode 100644 index 000000000..11bda8384 --- /dev/null +++ b/src/discord/commands/guild/d.mushroom_info.ts @@ -0,0 +1,89 @@ +import { + ActionRowBuilder, + AttachmentBuilder, + ButtonBuilder, + ButtonInteraction, + ButtonStyle, + Colors, + SlashCommandBuilder, +} from 'discord.js'; +import { SlashCommand } from '../../@types/commandDef'; +import { embedTemplate } from '../../utils/embedTemplate'; +// import mushroomInfo from '../../../global/commands/g.mushroomInfo'; +import commandContext from '../../utils/context'; +import { imageGet } from '../../utils/imageGet'; + +const F = f(__filename); + +const source = 'https://www.oaklandhyphae510.com/post/preliminary-tryptamine-potency-analysis-from-dried-homogenized-fruit-bodies-of-psilocybe-mushrooms'; +const disclaimer = 'The following data is based on preliminary research and development methods, does not represent final data and requires further peer review before being taken more seriously than \'interesting\'. However, this does represent meaningful, comparable data to the cultivators, to the consumers, and to the public.'; +const article = 'https://tripsitter.com/magic-mushrooms/average-potency/'; + +async function mushroomPageOneEmbed() { + return { + embeds: [embedTemplate() + .setTitle('Mushroom Potency Info') + .setColor(Colors.Green) + .setDescription(`${disclaimer} + + For more information check out [the source](${source}) and [this article](${article}).`) + .setImage('attachment://mushroomInfoA.png')], + files: [new AttachmentBuilder(await imageGet('mushroomInfoA'))], + + components: [new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId('mushroomPageTwo') + .setLabel('Show Visual') + .setStyle(ButtonStyle.Primary), + )], + }; +} + +async function mushroomPageTwoEmbed() { + return { + embeds: [embedTemplate() + .setTitle('Mushroom Potency Info') + .setColor(Colors.Green) + .setDescription(`${disclaimer} + + For more information check out [the source](${source}) and [this article](${article}).`) + .setImage('attachment://mushroomInfoB.png')], + files: [new AttachmentBuilder(await imageGet('mushroomInfoB'))], + + components: [new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setCustomId('mushroomPageOne') + .setLabel('Back to Data') + .setStyle(ButtonStyle.Danger), + )], + + }; +} + +export async function mushroomPageOne( + interaction:ButtonInteraction, +) { + // await interaction.deferUpdate(); + await interaction.update(await mushroomPageOneEmbed()); +} + +export async function mushroomPageTwo( + interaction:ButtonInteraction, +) { + // await interaction.deferUpdate(); + await interaction.update(await mushroomPageTwoEmbed()); +} + +export default { + data: new SlashCommandBuilder() + .setName('mushroom_info') + .setDescription('Displays different potencies of mushroom strains.') + .addBooleanOption(option => option.setName('ephemeral') + .setDescription('Set to "True" to show the response only to you')), + async execute(interaction) { + log.info(F, await commandContext(interaction)); + await interaction.deferReply({ ephemeral: (interaction.options.getBoolean('ephemeral') === true) }); + await interaction.editReply(await mushroomPageOneEmbed()); + return true; + }, +} as SlashCommand; diff --git a/src/discord/events/interactionCreate.ts b/src/discord/events/interactionCreate.ts index fba95b437..fa968d127 100644 --- a/src/discord/events/interactionCreate.ts +++ b/src/discord/events/interactionCreate.ts @@ -22,7 +22,7 @@ export const interactionCreate: InteractionCreateEvent = { name: 'interactionCreate', async execute(interaction) { const startTime = new Date().getTime(); - log.info(F, `interactionCreate event started at ${startTime}`); + // log.info(F, `interactionCreate event started at ${startTime}`); // Don't run anything if the interaction is from a bot if (interaction.user.bot) return; @@ -70,7 +70,7 @@ export const interactionCreate: InteractionCreateEvent = { if (interaction.isChatInputCommand()) { // Slash command // log.debug(F, `Interaction isChatInputCommand!`); - log.info(F, `Decided to run slash command in ${new Date().getTime() - startTime}ms`); + // log.info(F, `Decided to run slash command in ${new Date().getTime() - startTime}ms`); commandRun(interaction, discordClient); return; } @@ -78,7 +78,7 @@ export const interactionCreate: InteractionCreateEvent = { if (interaction.type === InteractionType.ApplicationCommand // Right click command && interaction.isContextMenuCommand()) { - log.debug(F, `interaction.isContextMenuCommand(): ${interaction.isContextMenuCommand()}`); + // log.debug(F, `interaction.isContextMenuCommand(): ${interaction.isContextMenuCommand()}`); commandRun(interaction, discordClient); return; } diff --git a/src/discord/utils/commandRun.ts b/src/discord/utils/commandRun.ts index 4b035e194..cf78c35ff 100644 --- a/src/discord/utils/commandRun.ts +++ b/src/discord/utils/commandRun.ts @@ -22,7 +22,7 @@ export async function commandRun( discordClient: Client, ) { const startTime = new Date().getTime(); - log.info(F, `commandRun started at ${startTime}`); + // log.info(F, `commandRun started at ${startTime}`); const { commandName } = interaction; const command = discordClient.commands.get(commandName); @@ -30,7 +30,7 @@ export async function commandRun( if (!command) return; try { - log.info(F, `Executed the command in ${new Date().getTime() - startTime}ms`); + // log.info(F, `Executed the command in ${new Date().getTime() - startTime}ms`); await command.execute(interaction); // log.info(F, `commandRun finished in ${new Date().getTime() - startTime}ms`); } catch (error) { diff --git a/src/discord/utils/imageGet.ts b/src/discord/utils/imageGet.ts index 731314800..f28c0bf49 100644 --- a/src/discord/utils/imageGet.ts +++ b/src/discord/utils/imageGet.ts @@ -75,6 +75,8 @@ const imageDef = { Memphis: { path: `${assetsDirectory}/img/backgrounds/Memphis.png`, url: 'https://drive.google.com/uc?export=view&id=117XLPb59h6V9op7GG7A6FFSvh07Any7-' }, Connected: { path: `${assetsDirectory}/img/backgrounds/Connected.png`, url: 'https://drive.google.com/uc?export=view&id=11AVKT7xrjI2ZgIpxz7j0zstBkD6XOD4m' }, Binary: { path: `${assetsDirectory}/img/backgrounds/Binary.png`, url: 'https://drive.google.com/uc?export=view&id=11Ocm9oq5jCqnWleZEZyk9yPsdSpQl6oK' }, + mushroomInfoA: { path: `${assetsDirectory}/img/mushroomInfoA.png`, url: 'https://i.gyazo.com/233df47085a0ac5493d8378111512b3d.png' }, + mushroomInfoB: { path: `${assetsDirectory}/img/mushroomInfoB.png`, url: 'https://i.gyazo.com/2aae45e843da99867b82e9b1ad07d22b.png' }, } as { [key: string]: { path: string; url: string; @@ -121,13 +123,14 @@ export async function imageGet( // If it does not exist, it will download it from the internet and save it to that location // Either way, it will return a working path to the image const { path, url } = imageDef[imageName]; - log.debug(F, `Checking ${path}`); + // log.debug(F, `Checking ${path}`); if (!fs.existsSync(path)) { - log.debug(F, `Downloading ${url} to ${path}`); + // log.debug(F, `Downloading ${url} to ${path}`); await downloadImage(url, path); - log.debug(F, `Downloaded ${url} to ${path}`); - } else { - log.debug(F, `Found ${path}`); + // log.debug(F, `Downloaded ${url} to ${path}`); } + // else { + // log.debug(F, `Found ${path}`); + // } return path; }