Last active
March 26, 2021 21:45
-
-
Save EricPedley/99e3c68a94487df22db80afc53098dbb to your computer and use it in GitHub Desktop.
Pylon discord bot script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Dict<TValue> { | |
| [key:string]:TValue | |
| } | |
| discord.on('MESSAGE_CREATE', async (message) => { | |
| if (message.author.bot) { | |
| const channel = await message.getChannel() as discord.GuildTextChannel; | |
| if (channel.name != 'bot-usage') | |
| await message.reply( | |
| 'https://tenor.com/view/discord-mods-discord-mods-soap-dont-drop-the-soap-gif-17881140' | |
| ); | |
| } else { | |
| if (message.content.startsWith('!react') && message.messageReference&&message.messageReference.messageId) { | |
| //if message starts with !react and is a reply | |
| console.log(message.content); | |
| const doDelete = message.content.endsWith("&delete") | |
| const word = message.content.slice(7,doDelete?message.content.indexOf("&delete"):undefined).toLowerCase(); | |
| const channel = await message.getChannel(); | |
| const previous = await channel.getMessage(message.messageReference.messageId); | |
| if(previous) { | |
| for(const character of word) { | |
| //127462 is '🇦'.codePointAt(0) | |
| const code = character.charCodeAt(0); | |
| const custom:Dict<string> = { | |
| 63:'❓', | |
| 33:'❗' | |
| } | |
| if(custom[code]) { | |
| await previous.addReaction(custom[code]) | |
| } | |
| if(code>96&&code<123) { | |
| //need to use codepoints instead of charCode because the regional indicator discord emojis are above 0xFFFF(https://datacadamia.com/data/type/text/surrogate) | |
| const addition = String.fromCodePoint(127462-97+code);//97 is the ascii value of lowercase a | |
| await previous.addReaction(addition); | |
| } | |
| } | |
| } | |
| if(message.content.endsWith("&delete")) { | |
| message.delete(); | |
| } | |
| } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment