From b7492c8ad0644a3edd411854ebb5c4a2d8977e06 Mon Sep 17 00:00:00 2001 From: ayeuhugyu Date: Sat, 30 Sep 2023 08:17:43 -0700 Subject: [PATCH] changed most discord actions to be handled by 1 script. this should cut down on errors and allow you to actually use the bot in other servers (i think) --- README.md | 4 + src/commands/addguildmember.js | 12 +- src/commands/addsound.js | 31 +++-- src/commands/commands.js | 10 +- src/commands/crash.js | 24 ++-- src/commands/createreactionrole.js | 146 +++++++-------------- src/commands/dmuser.js | 24 ++-- src/commands/eulogy.js | 15 +-- src/commands/git.js | 4 +- src/commands/guildmembers.js | 4 +- src/commands/joinvc.js | 7 +- src/commands/leavevc.js | 8 +- src/commands/links.js | 12 +- src/commands/mymovie.js | 5 +- src/commands/pepper.js | 7 +- src/commands/say.js | 13 +- src/commands/sendlog.js | 8 +- src/commands/soundboard.js | 13 +- src/commands/test.js | 24 +++- src/commands/vileimagery.js | 8 +- src/events/messageCreate.js | 4 +- src/index.js | 2 +- src/register-commands.js | 2 +- src/util/buildJson.js | 23 ---- src/util/buildRegex.js | 25 ---- src/util/discordAction.js | 82 ++++++++++++ src/util/irregulars.json | 204 ----------------------------- src/util/irregulars.txt | 202 ---------------------------- src/util/irregularsRegex.js | 1 - src/util/log.js | 22 ++-- 30 files changed, 262 insertions(+), 684 deletions(-) delete mode 100644 src/util/buildJson.js delete mode 100644 src/util/buildRegex.js create mode 100644 src/util/discordAction.js delete mode 100644 src/util/irregulars.json delete mode 100644 src/util/irregulars.txt delete mode 100644 src/util/irregularsRegex.js diff --git a/README.md b/README.md index 607c333..927138f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ clean up p/vileimagery, its horrendous **_Note:_** _versions before this were not uploaded to the repo, this is not the first version._ + 1.12 - changed most discord actions to be handled by 1 script. this should cut down on errors and allow you to actually use the bot in other servers (i think) + +--- + 1.11 - added PEPPERBOT VOICE CHAT CAPABILITY 1.11.1 - added ability to upload custom soundboard files diff --git a/src/commands/addguildmember.js b/src/commands/addguildmember.js index 37b29ee..cff97d8 100644 --- a/src/commands/addguildmember.js +++ b/src/commands/addguildmember.js @@ -1,4 +1,5 @@ import fs from "fs"; +import * as action from "../util/discordAction.js"; const prefix = process.env.PREFIX; function delay(time) { @@ -20,11 +21,14 @@ export default { const msgnoprefix = message.content.slice( prefix.length + this.name.length + 1 ); - const msg = msgnoprefix.slice(0, 2000); + const user = msgnoprefix.slice(0, 2000); - if (msg !== "") { - fs.appendFileSync("../pepperbot/data/guildmembers.log", msg + "\n"); - message.reply(`operation completed (๐Ÿค–); added ${msg} to members file`); + if (user !== "") { + fs.appendFileSync("../pepperbot/data/guildmembers.log", user + "\n"); + action.reply( + message, + `operation completed (๐Ÿค–); added ${user} to members file` + ); } } }, diff --git a/src/commands/addsound.js b/src/commands/addsound.js index 55d14f3..6946707 100644 --- a/src/commands/addsound.js +++ b/src/commands/addsound.js @@ -1,4 +1,5 @@ import fs from "fs"; +import * as action from "../util/discordAction.js"; import request from "request"; // yes i know this is deprecated i will fix it later (no i won't) function download(url, filename) { @@ -57,7 +58,8 @@ export default { filename ); if (success) { - message.reply( + action.reply( + message, `downloaded your file to \`resources/soundboard/${filename .toLowerCase() .replaceAll(" ", "_") @@ -67,30 +69,39 @@ export default { )}\`, if this name is different than the one you put, that's normal. all files are lowercased and "fixed."` ); } else { - message.reply( + action.reply( + message, "an unknown error occurred while attempting to download your file. see the console for details (id put it here but its probably too long for discord)" ); } } else { - message.reply( - `invalid file name! the file name either already exists, or you named it ls. don't name it ls.` + action.reply( + message, + `invalid file name! the file name either already exists, or you named it ls. don't name it ls. detected file name: \`${filename}\`` ); } } else { - message.reply( - `invalid file name! the file name either already exists, or you named it ls. don't name it ls.` + action.reply( + message, + `invalid file name! the file name either already exists, or you named it ls. don't name it ls. detected file name: \`${filename}\`` ); } } else { - message.reply("error has occurred; filename could not be split"); + action.reply( + message, + "error has occurred; filename could not be split" + ); } } else { - message.reply( - "invalid file extention; only `mp3`, `wav`, and `ogg` files are supported" + action.reply( + message, + `invalid file extention; only \`mp3\`, \`wav\`, and \`ogg\` files are supported. \`${ + filename.split(".")[1] + }\` is not.` ); } } else { - message.reply("no file detected"); + action.reply(message, "no file detected"); } }, }; diff --git a/src/commands/commands.js b/src/commands/commands.js index 548f127..942e3f0 100644 --- a/src/commands/commands.js +++ b/src/commands/commands.js @@ -1,4 +1,5 @@ import { EmbedBuilder } from "discord.js"; +import * as action from "../util/discordAction.js"; import fs from "fs"; export default { @@ -17,14 +18,11 @@ export default { const command = await import(`./${file}`); text += `p/${command.default.name} - ${command.default.description} - command arguments: ${command.default.arguments}\n \n`; } - const embed = new EmbedBuilder(); + const embed = action.createEmbed(); embed.setTitle("PepperBot Commands"); embed.setDescription(text); - embed.setColor(0xff0000); - embed.setThumbnail( - "https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" - ); - message.reply({ embeds: [embed] }); + + action.reply(message, { embeds: [embed] }); })(); }, }; diff --git a/src/commands/crash.js b/src/commands/crash.js index f61f961..8daee23 100644 --- a/src/commands/crash.js +++ b/src/commands/crash.js @@ -1,5 +1,6 @@ const whitelist = ["440163494529073152"]; -import fs from "fs"; +import * as action from "../util/discordAction.js"; +import { default as log } from "../util/log.js"; export default { name: "crash", @@ -7,26 +8,17 @@ export default { arguments: "none", execute(message, args) { if (whitelist.includes(message.author.id)) { - message.reply("crashing bot..."); - fs.appendFileSync( - "../pepperbot/src/logs/errors.log", + action.reply(message, "crashing bot..."); + log( + "errors.log", + message, + import.meta.url, "force crashed at " + Date() + "\n" ); throw "crash command executed"; } else { - message.reply("UNAUTHORIZED"); + action.reply(message, "UNAUTHORIZED"); const path = require("path"); - const scriptName = path.basename(__filename); - fs.appendFileSync( - "../pepperbot/src/logs/failed.log", - "non whitelisted user " + - message.author.username + - " (" + - message.author + - ") attempted accessing " + - scriptName + - "\n" - ); } }, }; diff --git a/src/commands/createreactionrole.js b/src/commands/createreactionrole.js index 24d0a54..0052efc 100644 --- a/src/commands/createreactionrole.js +++ b/src/commands/createreactionrole.js @@ -1,58 +1,7 @@ -import discord from "discord.js"; -//const emojiRegex = require("emoji-regex"); -//const irregularsRegex = require("../util/irregularsRegex.js"); -//const irregulars = require("../util/irregulars.json"); +import * as action from "../util/discordAction.js"; import fs from "fs"; import { default as log } from "../util/log.js"; -/*const getEmojis = (message) => { - const { content } = message; - const result = []; - // Normal emojis - const normalEmojis = content.match(emojiRegex()); - if (normalEmojis) { - // for (const emoji of normalEmojis) { - normalEmojis.forEach((emoji) => { - result.push(emoji); - }); - } - // Text emojis e.g โ™ฅ โœ‚ ๐Ÿ—จ - const textEmojis = content.match(irregularsRegex()); - if (textEmojis) { - textEmojis.forEach((emoji) => { - result.push(irregulars[emoji.trim()]); - }); - } - // Guild emojis - let guildEmojis = content.match(/:[_a-zA-Z0-9]*>/g); - if (guildEmojis) { - guildEmojis = guildEmojis.map((e) => e.substring(1, e.length - 1)); - guildEmojis.forEach((e) => { - try { - const guildEmoji = message.guild.emojis.get(e); - if (guildEmoji) { - result.push(guildEmoji); - } - } catch (error) { - console.log(error); - console.log("tried using guild emote lmao"); - } - }); - } - // Attempt to sort the results if its not null - if (result) { - const query = message.content; - result.sort((a, b) => { - const irregularA = getKeyByValue(irregulars, a); - const irregularB = getKeyByValue(irregulars, b); - const index1 = irregularA || a; - const index2 = irregularB || b; - return query.indexOf(index1) - query.indexOf(index2); - }); - } - return result; -};*/ - let collectors = []; const whitelist = ["440163494529073152", "436321340304392222"]; @@ -62,56 +11,49 @@ export default { description: "creates reaction role, requires whitelist", arguments: "emoji, user", execute(message, args) { - if (whitelist.includes(message.author.id)) { - let emojis = getEmojis(message); - let emoji = emojis[0]; - let role = message.mentions.roles.first(); - if (!role) { - log("failed.log", message, __filename, `role variable missing`); - return; + (async () => { + if (whitelist.includes(message.author.id)) { + let emoji = args[0]; + let role = message.mentions.roles.first(); + if (!role) { + log("failed.log", message, __filename, `role variable missing`); + return; + } + if (!emoji) { + log("failed.log", message, __filename, `emoji variable missing`); + return; + } + + const embed = action.createEmbed(); + + embed.setTitle(role.name); + embed.setDescription( + "React with " + emoji + " to recieve the " + role.name + " role." + ); + + const reactMessage = await action.sendMessage(message.channelId, { + embeds: [embed], + }); + + const collectorFilter = function (reaction) { + return true; + }; + + reactMessage.react(emoji); + + const collector = message.createReactionCollector({ + filter: collectorFilter, + }); + collectors.push(collector); + + collector.on("collect", (reaction, user) => { + console.log(`Collected ${reaction.emoji.name} from ${user.tag}`); + }); + } else { + action.reply(message, "UNAUTHORIZED"); + const path = require("path"); + const scriptName = path.basename(__filename); } - if (!emoji) { - log("failed.log", message, __filename, `emoji variable missing`); - return; - } - - const embed = new discord.EmbedBuilder(); - - embed.setThumbnail( - "https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" - ); - embed.setColor(0xff0000); - - embed.setTitle(role.name); - embed.setDescription( - "React with " + emoji + " to recieve the " + role.name + " role." - ); - - message.channel.send({ embeds: [embed] }).then((m) => m.react(emoji)); - - const collectorFilter = function (reaction) { - return true; - }; - - const collector = message.createReactionCollector({ - filter: collectorFilter, - }); - collectors.push(collector); - - collector.on("collect", (reaction, user) => { - console.log(`Collected ${reaction.emoji.name} from ${user.tag}`); - }); - } else { - message.reply("UNAUTHORIZED"); - const path = require("path"); - const scriptName = path.basename(__filename); - log( - "failed.log", - message, - __filename, - `non whitelisted user ${message.author.username} (${message.author}) attempted accessing ${scriptName}` - ); - fs.appendFileSync("../pepperbot/src/logs/failed.log"); - } + })(); }, }; diff --git a/src/commands/dmuser.js b/src/commands/dmuser.js index 5fa48ec..7e9ad23 100644 --- a/src/commands/dmuser.js +++ b/src/commands/dmuser.js @@ -1,15 +1,8 @@ import { default as log } from "../util/log.js"; -import * as dotenv from "dotenv"; -dotenv.config(); +import * as action from "../util/discordAction.js"; const prefix = process.env.PREFIX; -function delay(time) { - return new Promise((resolve) => { - setTimeout(resolve, time); - }); -} - export default { name: "dmuser", description: "forces bot to dm a user something (this will ghost ping them)", @@ -19,22 +12,23 @@ export default { const guild = message.guild; if (!user) { - return; + user = args[0]; + if (!user) { + return; + } } const msgnoprefix = message.content.slice( prefix.length + this.name.length + user.id.length + 4 ); - console.log(typeof user); - console.log(user.username); - const msg = msgnoprefix.slice(0, 2000); let ableToSend = true; if (msg !== "") { user.send(msg).catch(() => { - message.channel.send( + action.sendMessage( + message.channelId, `${message.author}, cannot send message to ${user}, this is usually caused by them not being inside the server` ); log( @@ -45,9 +39,7 @@ export default { ); ableToSend = false; }); - if (message.deletable) { - message.delete(); - } + action.messageDelete(message); if (ableToSend) { log( "forcesay.log", diff --git a/src/commands/eulogy.js b/src/commands/eulogy.js index fe4fa6b..1d132c7 100644 --- a/src/commands/eulogy.js +++ b/src/commands/eulogy.js @@ -1,6 +1,5 @@ import fs from "fs"; -import * as dotenv from "dotenv"; -dotenv.config(); +import * as action from "../util/discordAction.js"; const prefix = process.env.PREFIX; @@ -12,19 +11,19 @@ export default { const msgnoprefix = message.content.slice(prefix.length + this.name.length); const name = msgnoprefix.slice(0, 2000); const jsonstring = fs.readFileSync("../pepperbot/data/eulogies.json"); - const parsedeulogies = JSON.parse(jsonstring); - const maxRan = parsedeulogies.eulogies.length; + const parsedEulogies = JSON.parse(jsonstring); + const maxRan = parsedEulogies.eulogies.length; const randomnum = Math.floor(Math.random() * maxRan); - const eulogy = parsedeulogies.eulogies[randomnum]; + const eulogy = parsedEulogies.eulogies[randomnum]; if (name.replaceAll(" ", "") === "") { - message.reply("no name supplied"); + action.reply(message, "no name supplied"); return; } - const parsedeulogy = eulogy.replaceAll("##NAME", name); - message.reply(parsedeulogy); + const replacedEulogy = eulogy.replaceAll("##NAME", name); + action.reply(message, replacedEulogy); }, }; diff --git a/src/commands/git.js b/src/commands/git.js index d8ff2b7..ef391bd 100644 --- a/src/commands/git.js +++ b/src/commands/git.js @@ -1,8 +1,10 @@ +import * as action from "../util/discordAction.js"; + export default { name: "git", description: "posts open pepper repo", arguments: "none", execute(message, args) { - message.reply("https://git.reidlab.online/ayeuhugyu/PepperBot"); + action.reply(message, "https://git.reidlab.online/ayeuhugyu/PepperBot"); }, }; diff --git a/src/commands/guildmembers.js b/src/commands/guildmembers.js index 2cfb759..fccacd1 100644 --- a/src/commands/guildmembers.js +++ b/src/commands/guildmembers.js @@ -1,3 +1,5 @@ +import * as action from "../util/discordAction.js"; + export default { name: "guildmembers", description: @@ -5,7 +7,7 @@ export default { arguments: "none", execute(message, args) { const path = `../pepperbot/data/guildmembers.log`; - message.channel.send({ + action.sendMessage(message.channelId, { files: [ { attachment: path, diff --git a/src/commands/joinvc.js b/src/commands/joinvc.js index 237a7b9..8b9595c 100644 --- a/src/commands/joinvc.js +++ b/src/commands/joinvc.js @@ -1,6 +1,5 @@ import { joinVoiceChannel } from "@discordjs/voice"; -import * as dotenv from "dotenv"; -dotenv.config(); +import * as action from "../util/discordAction.js"; const guildId = process.env.GUILD_ID; @@ -18,9 +17,9 @@ export default { adapterCreator: voiceState.guild.voiceAdapterCreator, }); - message.reply(`connected to <#${voiceState.channelId}>`); + action.reply(message, `connected to <#${voiceState.channelId}>`); } else { - message.reply("u aint connected to a voice channel blud ๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚"); + action.reply(message, "u aint connected to a voice channel blud ๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚"); } }, }; diff --git a/src/commands/leavevc.js b/src/commands/leavevc.js index dbff137..aeae89f 100644 --- a/src/commands/leavevc.js +++ b/src/commands/leavevc.js @@ -1,4 +1,5 @@ import { getVoiceConnection } from "@discordjs/voice"; +import * as action from "../util/discordAction.js"; export default { name: "leavevc", @@ -8,9 +9,12 @@ export default { if (getVoiceConnection(message.guild.id)) { const connection = getVoiceConnection(message.guild.id); connection.destroy(); - message.reply(`left voice channel <#${connection.joinConfig.channelId}>`); + action.reply( + message, + `left voice channel <#${connection.joinConfig.channelId}>` + ); } else { - message.reply("im not connected to a voice channel here mf"); + action.reply(message, "im not connected to a voice channel here mf"); } }, }; diff --git a/src/commands/links.js b/src/commands/links.js index f36ad97..0c0802c 100644 --- a/src/commands/links.js +++ b/src/commands/links.js @@ -1,22 +1,18 @@ -import { EmbedBuilder } from "discord.js"; +import * as action from "../util/discordAction.js"; + export default { name: "links", description: 'posts "important" links', arguments: "none", execute(message, args) { - const embed = new EmbedBuilder(); + const embed = action.createEmbed(); embed.setTitle("very imphortance linkers"); - embed.setThumbnail( - "https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" - ); - embed.setColor(0xff0000); - embed.setDescription(` https://reidlab.online https://goop.network -- VERY IMPORTANT!!!! pepper.church releasing [TIME] (never (not anytime soon)) `); - message.reply({ embeds: [embed] }); + action.reply(message, { embeds: [embed] }); }, }; diff --git a/src/commands/mymovie.js b/src/commands/mymovie.js index 768b773..218369b 100644 --- a/src/commands/mymovie.js +++ b/src/commands/mymovie.js @@ -1,9 +1,12 @@ +import * as action from "../util/discordAction.js"; + export default { name: "mymovie", description: "posts my movie", arguments: "none", execute(message, args) { - message.reply( + action.reply( + message, "https://cdn.discordapp.com/attachments/755150633191080073/1149158052784775219/My_Movie.mp4" ); }, diff --git a/src/commands/pepper.js b/src/commands/pepper.js index 41ad7ad..54ddbe8 100644 --- a/src/commands/pepper.js +++ b/src/commands/pepper.js @@ -1,4 +1,4 @@ -import { EmbedBuilder } from "discord.js"; +import * as action from "../util/discordAction.js"; import fs from "fs"; export default { @@ -11,11 +11,10 @@ export default { const randomnum = Math.floor(Math.random() * maxRan); - const embed = new EmbedBuilder(); + const embed = action.createEmbed(); embed.setTitle("RANDOM PEPPER!!!"); embed.setImage(`attachment://${peppers[randomnum]}`); - embed.setColor(0xff0000); - message.reply({ + action.reply(message, { embeds: [embed], files: [`../pepperbot/resources/peppers/${peppers[randomnum]}`], }); diff --git a/src/commands/say.js b/src/commands/say.js index 3d2a42d..167e842 100644 --- a/src/commands/say.js +++ b/src/commands/say.js @@ -1,13 +1,8 @@ import { default as log } from "../util/log.js"; +import * as action from "../util/discordAction.js"; const prefix = process.env.PREFIX; -function delay(time) { - return new Promise((resolve) => { - setTimeout(resolve, time); - }); -} - export default { name: "say", description: "forces bot to say something", @@ -18,10 +13,8 @@ export default { const msg = msgnoprefix.slice(0, 2000); if (msg !== "") { - message.channel.send(msg); - if (message.deletable) { - message.delete(); - } + action.sendMessage(message.channelId, msg); + action.messageDelete(message); log( "forcesay.log", message, diff --git a/src/commands/sendlog.js b/src/commands/sendlog.js index 5599677..37e1341 100644 --- a/src/commands/sendlog.js +++ b/src/commands/sendlog.js @@ -1,4 +1,5 @@ const ignore = ["console.log"]; +import * as action from "../util/discordAction.js"; import fs from "fs"; export default { @@ -22,13 +23,13 @@ export default { .readdirSync("../pepperbot/logs/") .filter((file) => file.endsWith(".log")); if (!logs.includes(msgnoprefix)) { - message.reply("invalid log file"); + action.reply(message, "invalid log file"); return; } if (ignore.includes(msgnoprefix)) return; const path = `../pepperbot/logs/${msgnoprefix}`; if (!mobileMode) { - message.channel.send({ + action.sendMessage(message.channelId, { files: [ { attachment: path, @@ -39,7 +40,8 @@ export default { } else { const filestring = fs.readFileSync(path, "utf8"); console.log(typeof filestring); - message.channel.send( + action.sendMessage( + message.channelId, filestring.slice(filestring.length - 500, filestring.length) ); } diff --git a/src/commands/soundboard.js b/src/commands/soundboard.js index 308e31f..326f1e9 100644 --- a/src/commands/soundboard.js +++ b/src/commands/soundboard.js @@ -5,8 +5,7 @@ import { joinVoiceChannel, } from "@discordjs/voice"; import fs from "fs"; -import * as dotenv from "dotenv"; -dotenv.config(); +import * as action from "../util/discordAction.js"; const prefix = process.env.PREFIX; @@ -59,7 +58,8 @@ export default { } if (!file && !lsmode && !stopmode) { - message.reply( + action.reply( + message, "unable to find your file in the soundboard folder put `ls` as your args to upload a file of all names. try replacing spaces with _s. you proposed: " + proposedfilename ); @@ -78,9 +78,10 @@ export default { adapterCreator: voiceState.guild.voiceAdapterCreator, }); - message.reply(`connected to <#${voiceState.channelId}>`); + action.reply(message, `connected to <#${voiceState.channelId}>`); } else { - message.reply( + action.reply( + message, "the bot is not in a voice channel so a sound cannot be played, and you are not in a voice channel so it can't auto join. IDIOT!" ); return; @@ -90,7 +91,7 @@ export default { connection.subscribe(audioPlayer); audioPlayer.play(audioResource); } else { - message.channel.send({ + action.sendMessage(message.channelId, { files: [ { attachment: "resources/soundboard/ls.txt", diff --git a/src/commands/test.js b/src/commands/test.js index a9728ec..c11284e 100644 --- a/src/commands/test.js +++ b/src/commands/test.js @@ -1,14 +1,24 @@ +import * as action from "../util/discordAction.js"; + export default { name: "test", description: "test command", arguments: "all", execute(message, args) { - let text = - "command arguments test \nthis list should include all arguments you included in the command \n"; - for (let i = 0; i < args.length; i++) { - text += args[i] + "\n"; - } - - message.reply(text); + (async () => { + action.sendMessage(message.channelId, "channel send test"); + action.sendMainMessage("main message test"); + action.sendError("error test"); + const embed = action.createEmbed(); + embed.setTitle("EMBED TITLE"); + embed.setDescription("EMBED DESCRIPTION"); + action.sendMessage(message.channelId, { embeds: [embed] }); + const msg = await action.sendMainMessage("test"); + action.messageDelete(msg); + action.reply( + message, + "discord action script test completed without errors" + ); + })(); }, }; diff --git a/src/commands/vileimagery.js b/src/commands/vileimagery.js index b913342..e1859fb 100644 --- a/src/commands/vileimagery.js +++ b/src/commands/vileimagery.js @@ -1,5 +1,7 @@ import { EmbedBuilder } from "discord.js"; import fs from "fs"; +import * as action from "../util/discordAction.js"; + const prefix = process.env.PREFIX; export default { @@ -10,7 +12,7 @@ export default { let proposedfilename = message.content.slice( prefix.length + this.name.length + 1 ); - const embed = new EmbedBuilder(); + const embed = action.createEmbed(); const images = fs .readdirSync("../pepperbot/resources/vileimagery") .filter((file) => file.endsWith(".png")); @@ -49,12 +51,12 @@ export default { } embed.setColor(0xff0000); if (!lsMode) { - message.reply({ + action.reply(message, { embeds: [embed], files: [`../pepperbot/resources/vileimagery/${file}`], }); } else { - message.channel.send({ + action.sendMessage(message.channelId, { files: [ { attachment: path, diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 6298266..ca33235 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -64,6 +64,8 @@ export default function (message, client) { `use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`, true ); - commands.get(command).execute(message, args, client); + (async () => { + commands.get(command).execute(message, args, client); + })(); } } diff --git a/src/index.js b/src/index.js index e20dfcd..66dbbc9 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ import { GatewayIntentBits, Partials, Client } from "discord.js"; import events from "./events/importEvents.js"; import register from "./register-commands.js"; -const client = new Client({ +export const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, diff --git a/src/register-commands.js b/src/register-commands.js index 9d5deba..f63302f 100644 --- a/src/register-commands.js +++ b/src/register-commands.js @@ -27,7 +27,7 @@ async () => { ); } }; -console.log(commands); +//console.log(commands); const rest = new REST().setToken(process.env.TOKEN); diff --git a/src/util/buildJson.js b/src/util/buildJson.js deleted file mode 100644 index 88e6663..0000000 --- a/src/util/buildJson.js +++ /dev/null @@ -1,23 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const input = fs.readFileSync(path.resolve(__dirname, './irregulars.txt'), { - encoding: 'utf-8', -}); - -const data = input.split('\n'); - -const lines = data - .map((entry, i, arr) => { - const emojis = entry.split(','); - let jsonLine = ` "${emojis[1]}": "${emojis[0]}"`; - if (arr.length - 1 !== i) jsonLine += ','; - return jsonLine; - }) - .join('\n'); - -const json = `{\n${lines}\n}`; - -fs.writeFileSync(path.resolve(__dirname, 'irregulars.json'), json, { - encoding: 'utf-8', -}); \ No newline at end of file diff --git a/src/util/buildRegex.js b/src/util/buildRegex.js deleted file mode 100644 index a8b1a61..0000000 --- a/src/util/buildRegex.js +++ /dev/null @@ -1,25 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const base = '/โค/g'; - -const input = fs.readFileSync(path.resolve(__dirname, 'irregulars.txt'), { - encoding: 'utf-8', -}); - -const data = input.split('\n'); - -const piped = data - .map(emoji => { - const raw = emoji.split(',')[1]; - return raw.replace(/\*/g, '\\*'); - }) - .join('|'); - -const regex = base.replace(/โค/g, piped); - -const js = `module.exports = () => ${regex};`; - -fs.writeFileSync(path.resolve(__dirname, 'irregularsRegex.js'), js, { - encoding: 'utf-8', -}); \ No newline at end of file diff --git a/src/util/discordAction.js b/src/util/discordAction.js new file mode 100644 index 0000000..f097651 --- /dev/null +++ b/src/util/discordAction.js @@ -0,0 +1,82 @@ +import discord from "discord.js"; +import { default as log } from "./log.js"; +import * as index from "../index.js"; +const client = index.client; + +export async function sendMainMessage(message) { + const channel = client.channels.cache.get("1148814162273763418"); + const msg = await channel.send(message); + return msg; +} + +export function sendError(message) { + const channel = client.channels.cache.get("1148814162273763418"); + let msg; + try { + msg = channel.send(`**error:** ${message}`); + } catch (err) { + console.log(err); + return undefined; + } + return msg; +} + +export function messageDelete(message) { + if (!message) { + sendError("attempt to delete undefined message"); + return undefined; + } + if (message.deletable) { + message.delete(); + } else { + sendError( + `unable to delete message: ${message.url}. most likely caused by invalid permissions` + ); + console.log( + `unable to delete message: ${message.url}. most likely caused by invalid permissions` + ); + return undefined; + } +} + +export function sendMessage(channelId, message) { + (async () => { + const channel = client.channels.cache.get(channelId); + let msg; + if (channel) { + try { + msg = await channel.send(message); + return msg; + } catch (err) { + sendError(err.slice(err.length - 1750, err.length)); + console.log(err); + return undefined; + } + } else { + sendError(`unable to find channel: <#${channelId}>`); + } + })(); +} + +export function reply(triggerMessage, message) { + try { + (async () => { + let msg = await triggerMessage.reply(message); + return msg; + })(); + } catch (err) { + sendError(err.slice(err.length - 1750, err.length)); + console.log(err); + return undefined; + } +} + +export function createEmbed() { + const embed = new discord.EmbedBuilder(); + embed.setColor(0xff0000); + embed.setThumbnail( + "https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" + ); + + return embed; +} diff --git a/src/util/irregulars.json b/src/util/irregulars.json deleted file mode 100644 index 55939d3..0000000 --- a/src/util/irregulars.json +++ /dev/null @@ -1,204 +0,0 @@ -{ - "๐Ÿ…ฐ": ":a:", - "๐Ÿ…ฑ": ":b:", - "๐Ÿ…พ": ":o2:", - "๐Ÿ…ฟ": ":parking:", - "๐Ÿˆ‚": ":sa:", - "๐Ÿˆท": ":u6708:", - "๐ŸŒก": ":thermometer:", - "๐ŸŒค": ":white_sun_small_cloud:", - "๐ŸŒฅ": ":white_sun_cloud:", - "๐ŸŒฆ": ":white_sun_rain_cloud:", - "๐ŸŒง": ":cloud_rain:", - "๐ŸŒจ": ":cloud_snow:", - "๐ŸŒฉ": ":cloud_lightning:", - "๐ŸŒช": ":cloud_tornado:", - "๐ŸŒซ": ":fog:", - "๐ŸŒฌ": ":wind_blowing_face:", - "๐ŸŒถ": ":hot_pepper:", - "๐Ÿฝ": ":fork_knife_plate:", - "๐ŸŽ–": ":military_medal:", - "๐ŸŽ—": ":reminder_ribbon:", - "๐ŸŽ™": ":microphone2:", - "๐ŸŽš": ":level_slider:", - "๐ŸŽ›": ":control_knobs:", - "๐ŸŽž": ":film_frames:", - "๐ŸŽŸ": ":tickets:", - "๐Ÿ": ":motorcycle:", - "๐ŸŽ": ":race_car:", - "๐Ÿ”": ":mountain_snow:", - "๐Ÿ•": ":camping:", - "๐Ÿ–": ":beach:", - "๐Ÿ—": ":construction_site:", - "๐Ÿ˜": ":homes:", - "๐Ÿ™": ":cityscape:", - "๐Ÿš": ":house_abandoned:", - "๐Ÿ›": ":classical_building:", - "๐Ÿœ": ":desert:", - "๐Ÿ": ":island:", - "๐Ÿž": ":park:", - "๐ŸŸ": ":stadium:", - "๐Ÿณ": ":flag_white:", - "๐Ÿต": ":rosette:", - "๐Ÿท": ":label:", - "๐Ÿฟ": ":chipmunk:", - "๐Ÿ‘โ€๐Ÿ—จ": ":eye_in_speech_bubble:", - "๐Ÿ‘": ":eye:", - "๐Ÿ“ฝ": ":projector:", - "๐Ÿ•‰": ":om_symbol:", - "๐Ÿ•Š": ":dove:", - "๐Ÿ•ฏ": ":candle:", - "๐Ÿ•ฐ": ":clock:", - "๐Ÿ•ณ": ":hole:", - "๐Ÿ•ถ": ":dark_sunglasses:", - "๐Ÿ•ท": ":spider:", - "๐Ÿ•ธ": ":spider_web:", - "๐Ÿ•น": ":joystick:", - "๐Ÿ–‡": ":paperclips:", - "๐Ÿ–Š": ":pen_ballpoint:", - "๐Ÿ–‹": ":pen_fountain:", - "๐Ÿ–Œ": ":paintbrush:", - "๐Ÿ–": ":crayon:", - "๐Ÿ–ฅ": ":desktop:", - "๐Ÿ–จ": ":printer:", - "๐Ÿ–ฑ": ":mouse_three_button:", - "๐Ÿ–ฒ": ":trackball:", - "๐Ÿ–ผ": ":frame_photo:", - "๐Ÿ—‚": ":dividers:", - "๐Ÿ—ƒ": ":card_box:", - "๐Ÿ—„": ":file_cabinet:", - "๐Ÿ—‘": ":wastebasket:", - "๐Ÿ—’": ":notepad_spiral:", - "๐Ÿ—“": ":calendar_spiral:", - "๐Ÿ—œ": ":compression:", - "๐Ÿ—": ":key2:", - "๐Ÿ—ž": ":newspaper2:", - "๐Ÿ—ก": ":dagger:", - "๐Ÿ—ฃ": ":speaking_head:", - "๐Ÿ—จ": ":speech_left:", - "๐Ÿ—ฏ": ":anger_right:", - "๐Ÿ—ณ": ":ballot_box:", - "๐Ÿ—บ": ":map:", - "๐Ÿ›‹": ":couch:", - "๐Ÿ›": ":shopping_bags:", - "๐Ÿ›Ž": ":bellhop:", - "๐Ÿ›": ":bed:", - "๐Ÿ› ": ":tools:", - "๐Ÿ›ก": ":shield:", - "๐Ÿ›ข": ":oil:", - "๐Ÿ›ฃ": ":motorway:", - "๐Ÿ›ค": ":railway_track:", - "๐Ÿ›ฅ": ":motorboat:", - "๐Ÿ›ฉ": ":airplane_small:", - "๐Ÿ›ฐ": ":satellite_orbital:", - "๐Ÿ›ณ": ":cruise_ship:", - "โ€ผ": ":bangbang:", - "โ‰": ":interrobang:", - "โ„น": ":information_source:", - "โ†”": ":left_right_arrow:", - "โ†•": ":arrow_up_down:", - "โ†–": ":arrow_upper_left:", - "โ†—": ":arrow_upper_right:", - "โ†˜": ":arrow_lower_right:", - "โ†™": ":arrow_lower_left:", - "โ†ฉ": ":leftwards_arrow_with_hook:", - "โ†ช": ":arrow_right_hook:", - "#โƒฃ": ":hash:", - "โŒจ": ":keyboard:", - "โ": ":eject:", - "โญ": ":track_next:", - "โฎ": ":track_previous:", - "โฏ": ":play_pause:", - "โฑ": ":stopwatch:", - "โฒ": ":timer:", - "โธ": ":pause_button:", - "โน": ":stop_button:", - "โบ": ":record_button:", - "โ“‚": ":m:", - "โ–ช": ":black_small_square:", - "โ–ซ": ":white_small_square:", - "โ–ถ": ":arrow_forward:", - "โ—€": ":arrow_backward:", - "โ—ป": ":white_medium_square:", - "โ—ผ": ":black_medium_square:", - "โ˜€": ":sunny:", - "โ˜": ":cloud:", - "โ˜‚": ":umbrella2:", - "โ˜ƒ": ":snowman2:", - "โ˜„": ":comet:", - "โ˜Ž": ":telephone:", - "โ˜‘": ":ballot_box_with_check:", - "โ˜˜": ":shamrock:", - "โ˜ ": ":skull_crossbones:", - "โ˜ข": ":radioactive:", - "โ˜ฃ": ":biohazard:", - "โ˜ฆ": ":orthodox_cross:", - "โ˜ช": ":star_and_crescent:", - "โ˜ฎ": ":peace:", - "โ˜ฏ": ":yin_yang:", - "โ˜ธ": ":wheel_of_dharma:", - "โ˜น": ":frowning2:", - "โ˜บ": ":relaxed:", - "โ™ ": ":spades:", - "โ™ฃ": ":clubs:", - "โ™ฅ": ":hearts:", - "โ™ฆ": ":diamonds:", - "โ™จ": ":hotsprings:", - "โ™ป": ":recycle:", - "โš’": ":hammer_pick:", - "โš”": ":crossed_swords:", - "โš–": ":scales:", - "โš—": ":alembic:", - "โš™": ":gear:", - "โš›": ":atom:", - "โšœ": ":fleur_de_lis:", - "โš ": ":warning:", - "โšฐ": ":coffin:", - "โšฑ": ":urn:", - "โ›ˆ": ":thunder_cloud_rain:", - "โ›": ":pick:", - "โ›‘": ":helmet_with_cross:", - "โ›“": ":chains:", - "โ›ฉ": ":shinto_shrine:", - "โ›ฐ": ":mountain:", - "โ›ฑ": ":beach_umbrella:", - "โ›ด": ":ferry:", - "โ›ท": ":skier:", - "โ›ธ": ":ice_skate:", - "โœ‚": ":scissors:", - "โœˆ": ":airplane:", - "โœ‰": ":envelope:", - "โœ": ":pencil2:", - "โœ’": ":black_nib:", - "โœ”": ":heavy_check_mark:", - "โœ–": ":heavy_multiplication_x:", - "โœ": ":cross:", - "โœก": ":star_of_david:", - "โœณ": ":eight_spoked_asterisk:", - "โœด": ":eight_pointed_black_star:", - "โ„": ":snowflake:", - "โ‡": ":sparkle:", - "โฃ": ":heart_exclamation:", - "โค": ":heart:", - "โžก": ":arrow_right:", - "โคด": ":arrow_heading_up:", - "โคต": ":arrow_heading_down:", - "*โƒฃ": ":asterisk:", - "โฌ…": ":arrow_left:", - "โฌ†": ":arrow_up:", - "โฌ‡": ":arrow_down:", - "0โƒฃ": ":zero:", - "ใ€ฐ": ":wavy_dash:", - "ใ€ฝ": ":part_alternation_mark:", - "1โƒฃ": ":one:", - "2โƒฃ": ":two:", - "ใŠ—": ":congratulations:", - "ใŠ™": ":secret:", - "3โƒฃ": ":three:", - "4โƒฃ": ":four:", - "5โƒฃ": ":five:", - "6โƒฃ": ":six:", - "7โƒฃ": ":seven:", - "8โƒฃ": ":eight:", - "9โƒฃ": ":nine:" - } \ No newline at end of file diff --git a/src/util/irregulars.txt b/src/util/irregulars.txt deleted file mode 100644 index 9390d31..0000000 --- a/src/util/irregulars.txt +++ /dev/null @@ -1,202 +0,0 @@ -:a:,๐Ÿ…ฐ -:b:,๐Ÿ…ฑ -:o2:,๐Ÿ…พ -:parking:,๐Ÿ…ฟ -:sa:,๐Ÿˆ‚ -:u6708:,๐Ÿˆท -:thermometer:,๐ŸŒก -:white_sun_small_cloud:,๐ŸŒค -:white_sun_cloud:,๐ŸŒฅ -:white_sun_rain_cloud:,๐ŸŒฆ -:cloud_rain:,๐ŸŒง -:cloud_snow:,๐ŸŒจ -:cloud_lightning:,๐ŸŒฉ -:cloud_tornado:,๐ŸŒช -:fog:,๐ŸŒซ -:wind_blowing_face:,๐ŸŒฌ -:hot_pepper:,๐ŸŒถ -:fork_knife_plate:,๐Ÿฝ -:military_medal:,๐ŸŽ– -:reminder_ribbon:,๐ŸŽ— -:microphone2:,๐ŸŽ™ -:level_slider:,๐ŸŽš -:control_knobs:,๐ŸŽ› -:film_frames:,๐ŸŽž -:tickets:,๐ŸŽŸ -:motorcycle:,๐Ÿ -:race_car:,๐ŸŽ -:mountain_snow:,๐Ÿ” -:camping:,๐Ÿ• -:beach:,๐Ÿ– -:construction_site:,๐Ÿ— -:homes:,๐Ÿ˜ -:cityscape:,๐Ÿ™ -:house_abandoned:,๐Ÿš -:classical_building:,๐Ÿ› -:desert:,๐Ÿœ -:island:,๐Ÿ -:park:,๐Ÿž -:stadium:,๐ŸŸ -:flag_white:,๐Ÿณ -:rosette:,๐Ÿต -:label:,๐Ÿท -:chipmunk:,๐Ÿฟ -:eye_in_speech_bubble:,๐Ÿ‘โ€๐Ÿ—จ -:eye:,๐Ÿ‘ -:projector:,๐Ÿ“ฝ -:om_symbol:,๐Ÿ•‰ -:dove:,๐Ÿ•Š -:candle:,๐Ÿ•ฏ -:clock:,๐Ÿ•ฐ -:hole:,๐Ÿ•ณ -:dark_sunglasses:,๐Ÿ•ถ -:spider:,๐Ÿ•ท -:spider_web:,๐Ÿ•ธ -:joystick:,๐Ÿ•น -:paperclips:,๐Ÿ–‡ -:pen_ballpoint:,๐Ÿ–Š -:pen_fountain:,๐Ÿ–‹ -:paintbrush:,๐Ÿ–Œ -:crayon:,๐Ÿ– -:desktop:,๐Ÿ–ฅ -:printer:,๐Ÿ–จ -:mouse_three_button:,๐Ÿ–ฑ -:trackball:,๐Ÿ–ฒ -:frame_photo:,๐Ÿ–ผ -:dividers:,๐Ÿ—‚ -:card_box:,๐Ÿ—ƒ -:file_cabinet:,๐Ÿ—„ -:wastebasket:,๐Ÿ—‘ -:notepad_spiral:,๐Ÿ—’ -:calendar_spiral:,๐Ÿ—“ -:compression:,๐Ÿ—œ -:key2:,๐Ÿ— -:newspaper2:,๐Ÿ—ž -:dagger:,๐Ÿ—ก -:speaking_head:,๐Ÿ—ฃ -:speech_left:,๐Ÿ—จ -:anger_right:,๐Ÿ—ฏ -:ballot_box:,๐Ÿ—ณ -:map:,๐Ÿ—บ -:couch:,๐Ÿ›‹ -:shopping_bags:,๐Ÿ› -:bellhop:,๐Ÿ›Ž -:bed:,๐Ÿ› -:tools:,๐Ÿ›  -:shield:,๐Ÿ›ก -:oil:,๐Ÿ›ข -:motorway:,๐Ÿ›ฃ -:railway_track:,๐Ÿ›ค -:motorboat:,๐Ÿ›ฅ -:airplane_small:,๐Ÿ›ฉ -:satellite_orbital:,๐Ÿ›ฐ -:cruise_ship:,๐Ÿ›ณ -:bangbang:,โ€ผ -:interrobang:,โ‰ -:information_source:,โ„น -:left_right_arrow:,โ†” -:arrow_up_down:,โ†• -:arrow_upper_left:,โ†– -:arrow_upper_right:,โ†— -:arrow_lower_right:,โ†˜ -:arrow_lower_left:,โ†™ -:leftwards_arrow_with_hook:,โ†ฉ -:arrow_right_hook:,โ†ช -:hash:,#โƒฃ -:keyboard:,โŒจ -:eject:,โ -:track_next:,โญ -:track_previous:,โฎ -:play_pause:,โฏ -:stopwatch:,โฑ -:timer:,โฒ -:pause_button:,โธ -:stop_button:,โน -:record_button:,โบ -:m:,โ“‚ -:black_small_square:,โ–ช -:white_small_square:,โ–ซ -:arrow_forward:,โ–ถ -:arrow_backward:,โ—€ -:white_medium_square:,โ—ป -:black_medium_square:,โ—ผ -:sunny:,โ˜€ -:cloud:,โ˜ -:umbrella2:,โ˜‚ -:snowman2:,โ˜ƒ -:comet:,โ˜„ -:telephone:,โ˜Ž -:ballot_box_with_check:,โ˜‘ -:shamrock:,โ˜˜ -:skull_crossbones:,โ˜  -:radioactive:,โ˜ข -:biohazard:,โ˜ฃ -:orthodox_cross:,โ˜ฆ -:star_and_crescent:,โ˜ช -:peace:,โ˜ฎ -:yin_yang:,โ˜ฏ -:wheel_of_dharma:,โ˜ธ -:frowning2:,โ˜น -:relaxed:,โ˜บ -:spades:,โ™  -:clubs:,โ™ฃ -:hearts:,โ™ฅ -:diamonds:,โ™ฆ -:hotsprings:,โ™จ -:recycle:,โ™ป -:hammer_pick:,โš’ -:crossed_swords:,โš” -:scales:,โš– -:alembic:,โš— -:gear:,โš™ -:atom:,โš› -:fleur_de_lis:,โšœ -:warning:,โš  -:coffin:,โšฐ -:urn:,โšฑ -:thunder_cloud_rain:,โ›ˆ -:pick:,โ› -:helmet_with_cross:,โ›‘ -:chains:,โ›“ -:shinto_shrine:,โ›ฉ -:mountain:,โ›ฐ -:beach_umbrella:,โ›ฑ -:ferry:,โ›ด -:skier:,โ›ท -:ice_skate:,โ›ธ -:scissors:,โœ‚ -:airplane:,โœˆ -:envelope:,โœ‰ -:pencil2:,โœ -:black_nib:,โœ’ -:heavy_check_mark:,โœ” -:heavy_multiplication_x:,โœ– -:cross:,โœ -:star_of_david:,โœก -:eight_spoked_asterisk:,โœณ -:eight_pointed_black_star:,โœด -:snowflake:,โ„ -:sparkle:,โ‡ -:heart_exclamation:,โฃ -:heart:,โค -:arrow_right:,โžก -:arrow_heading_up:,โคด -:arrow_heading_down:,โคต -:asterisk:,*โƒฃ -:arrow_left:,โฌ… -:arrow_up:,โฌ† -:arrow_down:,โฌ‡ -:zero:,0โƒฃ -:wavy_dash:,ใ€ฐ -:part_alternation_mark:,ใ€ฝ -:one:,1โƒฃ -:two:,2โƒฃ -:congratulations:,ใŠ— -:secret:,ใŠ™ -:three:,3โƒฃ -:four:,4โƒฃ -:five:,5โƒฃ -:six:,6โƒฃ -:seven:,7โƒฃ -:eight:,8โƒฃ -:nine:,9โƒฃ \ No newline at end of file diff --git a/src/util/irregularsRegex.js b/src/util/irregularsRegex.js deleted file mode 100644 index 9d3837f..0000000 --- a/src/util/irregularsRegex.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => /๐Ÿ…ฐ|๐Ÿ…ฑ|๐Ÿ…พ|๐Ÿ…ฟ|๐Ÿˆ‚|๐Ÿˆท|๐ŸŒก|๐ŸŒค|๐ŸŒฅ|๐ŸŒฆ|๐ŸŒง|๐ŸŒจ|๐ŸŒฉ|๐ŸŒช|๐ŸŒซ|๐ŸŒฌ|๐ŸŒถ|๐Ÿฝ|๐ŸŽ–|๐ŸŽ—|๐ŸŽ™|๐ŸŽš|๐ŸŽ›|๐ŸŽž|๐ŸŽŸ|๐Ÿ|๐ŸŽ|๐Ÿ”|๐Ÿ•|๐Ÿ–|๐Ÿ—|๐Ÿ˜|๐Ÿ™|๐Ÿš|๐Ÿ›|๐Ÿœ|๐Ÿ|๐Ÿž|๐ŸŸ|๐Ÿณ|๐Ÿต|๐Ÿท|๐Ÿฟ|๐Ÿ‘โ€๐Ÿ—จ|๐Ÿ‘|๐Ÿ“ฝ|๐Ÿ•‰|๐Ÿ•Š|๐Ÿ•ฏ|๐Ÿ•ฐ|๐Ÿ•ณ|๐Ÿ•ถ|๐Ÿ•ท|๐Ÿ•ธ|๐Ÿ•น|๐Ÿ–‡|๐Ÿ–Š|๐Ÿ–‹|๐Ÿ–Œ|๐Ÿ–|๐Ÿ–ฅ|๐Ÿ–จ|๐Ÿ–ฑ|๐Ÿ–ฒ|๐Ÿ–ผ|๐Ÿ—‚|๐Ÿ—ƒ|๐Ÿ—„|๐Ÿ—‘|๐Ÿ—’|๐Ÿ—“|๐Ÿ—œ|๐Ÿ—|๐Ÿ—ž|๐Ÿ—ก|๐Ÿ—ฃ|๐Ÿ—จ|๐Ÿ—ฏ|๐Ÿ—ณ|๐Ÿ—บ|๐Ÿ›‹|๐Ÿ›|๐Ÿ›Ž|๐Ÿ›|๐Ÿ› |๐Ÿ›ก|๐Ÿ›ข|๐Ÿ›ฃ|๐Ÿ›ค|๐Ÿ›ฅ|๐Ÿ›ฉ|๐Ÿ›ฐ|๐Ÿ›ณ|โ€ผ|โ‰|โ„น|โ†”|โ†•|โ†–|โ†—|โ†˜|โ†™|โ†ฉ|โ†ช|#โƒฃ|โŒจ|โ|โญ|โฎ|โฏ|โฑ|โฒ|โธ|โน|โบ|โ“‚|โ–ช|โ–ซ|โ–ถ|โ—€|โ—ป|โ—ผ|โ˜€|โ˜|โ˜‚|โ˜ƒ|โ˜„|โ˜Ž|โ˜‘|โ˜˜|โ˜ |โ˜ข|โ˜ฃ|โ˜ฆ|โ˜ช|โ˜ฎ|โ˜ฏ|โ˜ธ|โ˜น|โ˜บ|โ™ |โ™ฃ|โ™ฅ|โ™ฆ|โ™จ|โ™ป|โš’|โš”|โš–|โš—|โš™|โš›|โšœ|โš |โšฐ|โšฑ|โ›ˆ|โ›|โ›‘|โ›“|โ›ฉ|โ›ฐ|โ›ฑ|โ›ด|โ›ท|โ›ธ|โœ‚|โœˆ|โœ‰|โœ|โœ’|โœ”|โœ–|โœ|โœก|โœณ|โœด|โ„|โ‡|โฃ|โค|โžก|โคด|โคต|\*โƒฃ|โฌ…|โฌ†|โฌ‡|0โƒฃ|ใ€ฐ|ใ€ฝ|1โƒฃ|2โƒฃ|ใŠ—|ใŠ™|3โƒฃ|4โƒฃ|5โƒฃ|6โƒฃ|7โƒฃ|8โƒฃ|9โƒฃ/g; \ No newline at end of file diff --git a/src/util/log.js b/src/util/log.js index bd0967a..65a8589 100644 --- a/src/util/log.js +++ b/src/util/log.js @@ -1,23 +1,17 @@ import fs from "fs"; -export default function (file, message, from, msg, noconsole) { - fs.appendFileSync( - `../pepperbot/logs/${file}`, - `AT: ${Date()} -SCRIPT: ${from} +export default function (file, message, from, msg) { + try { + fs.appendFileSync( + `../pepperbot/logs/${file}`, + `AT: ${Date()} +SCRIPT: ${from} +IN: <#${message.channel.id}> MESSAGE CONTENT: ${message.content} ADDITIONAL INFORMATION: ${msg} \n` - ); - if (!noconsole) { - console.log( - `AT: ${Date()} - SCRIPT: ${from} - MESSAGE CONTENT: ${message.content} - ADDITIONAL INFORMATION: ${msg} - ` ); - } + } catch (err) {} } // TEMPLATE: