From df8be80f6d7f567f087f24a0e7420280764b673f Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Wed, 6 Sep 2023 11:19:02 +1000 Subject: [PATCH] Create FAQStore, will do more later at some point. --- src/commands/faq.ts | 20 +++++++++++--------- src/helpers/FAQStore.ts | 10 ++++++++++ src/helpers/MessageTool.ts | 3 +++ 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 src/helpers/FAQStore.ts diff --git a/src/commands/faq.ts b/src/commands/faq.ts index 1778954..107e7a9 100644 --- a/src/commands/faq.ts +++ b/src/commands/faq.ts @@ -1,6 +1,7 @@ import Discord from 'discord.js'; import TClient from '../client.js'; import MessageTool from '../helpers/MessageTool.js'; +import FAQStore from '../helpers/FAQStore.js'; export default { run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ const verifyFaq = MessageTool.concatMessage( @@ -17,16 +18,17 @@ export default { '3. Epic Launcher will scan your game installation directory and will re-download anything that is corrupted or tampered with.', '```' ); + const youCanGetRole = (role:string, roleEmoji:string)=>`You can get the ${MessageTool.formatMention(client.config.mainServer.roles[role], 'role')} role from <#802283932430106624> by clicking :${roleEmoji}: button on a webhook's message.`; ({ - srp: ()=>interaction.reply('[Ballyspring]() is the map that is used in Survival Roleplay S4.\n\n> ℹ️ __Note__\n> The map won\'t look closely like the one in SRP as it is privately edited version of the public map.'), - vtcR: ()=>interaction.reply(`You can get the <@&${client.config.mainServer.roles.vtcmember}> role from <#802283932430106624> by clicking :truck: button on a webhook's message\n*VTC skin can also be found in <#801975222609641472> as well.*`), - mpR: ()=>interaction.reply(`You can get the <@&${client.config.mainServer.roles.mpplayer}> role from <#802283932430106624> by clicking :tractor: button on webhook's message`), - ytscam: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Scammers in YouTube comments section', 'If you ever see a comment mentioning a giveaway or anything else, **it\'s a scam!**\nYou should report it to YouTube and move on or ignore it.\nP.S: They\'re on every channel and not just Daggerwin.', 'https://cdn.discordapp.com/attachments/1015195575693627442/1068078284996345916/image.png')]}), - steamscam: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Steam account report scam', 'If you received a DM about this, please report it to Discord Moderators or open a [ticket](https://discord.com/channels/468835415093411861/942173932339986472/1054128182468546631)', 'https://cdn.discordapp.com/attachments/1091300529696673792/1122266621088645130/image.png')]}), - fsVerifyGame: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Verifying your game files', `You can verify your game files if you experience any issues with your game.\n${verifyFaq}`, 'https://cdn.discordapp.com/attachments/1015195575693627442/1138185771971526757/Steam-Epic-VerifyGamesLocation.png')]}), - fsShader: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Clearing your shader cache folder', 'If your game keeps crashing shortly after opening your game, then the shaders might be an issue.\nTo resolve this, you can go to `Documents/My Games/FarmingSimulator2022` and delete the folder called `shader_cache`', 'https://cdn.discordapp.com/attachments/1015195575693627442/1015195687970943016/unknown.png')]}), - fsLogfile: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Uploading your log file', 'You can find `log.txt` in `Documents/My Games/FarmingSimulator2022` and upload it into <#596989522395398144> along with your issue, so people can assist you further and help you resolve.', 'https://cdn.discordapp.com/attachments/1015195575693627442/1015195643528101958/unknown.png')]}), - fsDevConsole: ()=>interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, 'Enabling the development console', 'Head over to `game.xml` in `Documents/My Games/FarmingSimulator2022` and find the section that mentions `false` inside development section, change it to `true` then you are good to go!\nFYI: The keybind to open console is \``\u200b\` (backtick).', 'https://cdn.discordapp.com/attachments/1015195575693627442/1097273921444790322/image.png')]}) + srp: ()=>FAQStore.reply(null, interaction, null, '[Ballyspring]() is the map that is used in Survival Roleplay S4.\n\n> ℹ️ __Note__\n> The map won\'t look closely like the one in SRP as it is privately edited version of the public map.', null, false), + vtcR: ()=>interaction.reply(youCanGetRole('vtcmember', 'truck')+'\n*VTC skin can also be found in <#801975222609641472> as well.*'), + mpR: ()=>interaction.reply(youCanGetRole('mpplayer', 'tractor')), + ytscam: ()=>FAQStore.reply(client, interaction, 'Scammers in YouTube comments section', 'If you ever see a comment mentioning a giveaway or anything else, **it\'s a scam!**\nYou should report it to YouTube and move on or ignore it.\nP.S: They\'re on every channel and not just Daggerwin.', 'https://cdn.discordapp.com/attachments/1015195575693627442/1068078284996345916/image.png', true), + steamscam: ()=>FAQStore.reply(client, interaction, 'Steam account report scam', 'If you received a DM about this, please report it to Discord Moderators or open a [ticket](https://discord.com/channels/468835415093411861/942173932339986472/1054128182468546631)', 'https://cdn.discordapp.com/attachments/1091300529696673792/1122266621088645130/image.png', true), + fsVerifyGame: ()=>FAQStore.reply(client, interaction, 'Verifying your game files', `You can verify your game files if you experience any issues with your game.\n${verifyFaq}`, 'https://cdn.discordapp.com/attachments/1015195575693627442/1138185771971526757/Steam-Epic-VerifyGamesLocation.png', true), + fsShader: ()=>FAQStore.reply(client, interaction, 'Clearing your shader cache folder', 'If your game keeps crashing shortly after opening your game, then the shaders might be an issue.\nTo resolve this, you can go to `Documents/My Games/FarmingSimulator2022` and delete the folder called `shader_cache`', 'https://cdn.discordapp.com/attachments/1015195575693627442/1015195687970943016/unknown.png', true), + fsLogfile: ()=>FAQStore.reply(client, interaction, 'Uploading your log file', 'You can find `log.txt` in `Documents/My Games/FarmingSimulator2022` and upload it into <#596989522395398144> along with your issue, so people can assist you further and help you resolve.', 'https://cdn.discordapp.com/attachments/1015195575693627442/1015195643528101958/unknown.png', true), + fsDevConsole: ()=>FAQStore.reply(client, interaction, 'Enabling the development console', 'Head over to `game.xml` in `Documents/My Games/FarmingSimulator2022` and find the section that mentions `false` inside development section, change it to `true` then you are good to go!\nFYI: The keybind to open console is \``\u200b\` (backtick).', 'https://cdn.discordapp.com/attachments/1015195575693627442/1097273921444790322/image.png', true) } as any)[interaction.options.getString('question', true)](); }, data: new Discord.SlashCommandBuilder() diff --git a/src/helpers/FAQStore.ts b/src/helpers/FAQStore.ts new file mode 100644 index 0000000..3178023 --- /dev/null +++ b/src/helpers/FAQStore.ts @@ -0,0 +1,10 @@ +import Discord from 'discord.js'; +import TClient from '../client.js'; +import MessageTool from './MessageTool.js'; +export default class FAQStore { + protected static readonly errorMsg:string = 'Failed to send the message, please report to **Toast** if it continues.'; + static async reply(client:TClient|null, interaction:Discord.ChatInputCommandInteraction, title:string|null, message:string, image:string|null, useEmbed:boolean=false) { + if (useEmbed) return interaction.reply({embeds: [MessageTool.embedStruct(client.config.embedColor, title, message, image)]}).catch(err=>interaction.reply(this.errorMsg+'\n'+err)) + else return interaction.reply(message).catch(err=>interaction.reply(this.errorMsg+'\n'+err)) + } +} diff --git a/src/helpers/MessageTool.ts b/src/helpers/MessageTool.ts index 18c0fff..b9517ca 100644 --- a/src/helpers/MessageTool.ts +++ b/src/helpers/MessageTool.ts @@ -16,5 +16,8 @@ export default class MessageTool { static concatMessage(...messages:string[]){ return messages.join('\n') } + static formatMention(mention:string, type:'user'|'channel'|'role'){ + return `<@${type === 'role' ? '&' : type === 'channel' ? '#' : ''}${mention}>` + } } // I want to come up with better name instead of calling this file "MessageTool", but I am super bad at naming things.