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)

This commit is contained in:
ayeuhugyu 2023-09-30 08:17:43 -07:00
parent c97762e84c
commit b7492c8ad0
30 changed files with 262 additions and 684 deletions

View file

@ -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._ **_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 - added PEPPERBOT VOICE CHAT CAPABILITY
1.11.1 - added ability to upload custom soundboard files 1.11.1 - added ability to upload custom soundboard files

View file

@ -1,4 +1,5 @@
import fs from "fs"; import fs from "fs";
import * as action from "../util/discordAction.js";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
function delay(time) { function delay(time) {
@ -20,11 +21,14 @@ export default {
const msgnoprefix = message.content.slice( const msgnoprefix = message.content.slice(
prefix.length + this.name.length + 1 prefix.length + this.name.length + 1
); );
const msg = msgnoprefix.slice(0, 2000); const user = msgnoprefix.slice(0, 2000);
if (msg !== "") { if (user !== "") {
fs.appendFileSync("../pepperbot/data/guildmembers.log", msg + "\n"); fs.appendFileSync("../pepperbot/data/guildmembers.log", user + "\n");
message.reply(`operation completed (🤖); added ${msg} to members file`); action.reply(
message,
`operation completed (🤖); added ${user} to members file`
);
} }
} }
}, },

View file

@ -1,4 +1,5 @@
import fs from "fs"; 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) import request from "request"; // yes i know this is deprecated i will fix it later (no i won't)
function download(url, filename) { function download(url, filename) {
@ -57,7 +58,8 @@ export default {
filename filename
); );
if (success) { if (success) {
message.reply( action.reply(
message,
`downloaded your file to \`resources/soundboard/${filename `downloaded your file to \`resources/soundboard/${filename
.toLowerCase() .toLowerCase()
.replaceAll(" ", "_") .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."` )}\`, if this name is different than the one you put, that's normal. all files are lowercased and "fixed."`
); );
} else { } 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)" "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 { } else {
message.reply( action.reply(
`invalid file name! the file name either already exists, or you named it ls. don't name it ls.` 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 { } else {
message.reply( action.reply(
`invalid file name! the file name either already exists, or you named it ls. don't name it ls.` 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 { } else {
message.reply("error has occurred; filename could not be split"); action.reply(
message,
"error has occurred; filename could not be split"
);
} }
} else { } else {
message.reply( action.reply(
"invalid file extention; only `mp3`, `wav`, and `ogg` files are supported" message,
`invalid file extention; only \`mp3\`, \`wav\`, and \`ogg\` files are supported. \`${
filename.split(".")[1]
}\` is not.`
); );
} }
} else { } else {
message.reply("no file detected"); action.reply(message, "no file detected");
} }
}, },
}; };

View file

@ -1,4 +1,5 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
import * as action from "../util/discordAction.js";
import fs from "fs"; import fs from "fs";
export default { export default {
@ -17,14 +18,11 @@ export default {
const command = await import(`./${file}`); const command = await import(`./${file}`);
text += `p/${command.default.name} - ${command.default.description} - command arguments: ${command.default.arguments}\n \n`; 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.setTitle("PepperBot Commands");
embed.setDescription(text); embed.setDescription(text);
embed.setColor(0xff0000);
embed.setThumbnail( action.reply(message, { embeds: [embed] });
"https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png"
);
message.reply({ embeds: [embed] });
})(); })();
}, },
}; };

View file

@ -1,5 +1,6 @@
const whitelist = ["440163494529073152"]; const whitelist = ["440163494529073152"];
import fs from "fs"; import * as action from "../util/discordAction.js";
import { default as log } from "../util/log.js";
export default { export default {
name: "crash", name: "crash",
@ -7,26 +8,17 @@ export default {
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
if (whitelist.includes(message.author.id)) { if (whitelist.includes(message.author.id)) {
message.reply("crashing bot..."); action.reply(message, "crashing bot...");
fs.appendFileSync( log(
"../pepperbot/src/logs/errors.log", "errors.log",
message,
import.meta.url,
"force crashed at " + Date() + "\n" "force crashed at " + Date() + "\n"
); );
throw "crash command executed"; throw "crash command executed";
} else { } else {
message.reply("UNAUTHORIZED"); action.reply(message, "UNAUTHORIZED");
const path = require("path"); 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"
);
} }
}, },
}; };

View file

@ -1,58 +1,7 @@
import discord from "discord.js"; import * as action from "../util/discordAction.js";
//const emojiRegex = require("emoji-regex");
//const irregularsRegex = require("../util/irregularsRegex.js");
//const irregulars = require("../util/irregulars.json");
import fs from "fs"; import fs from "fs";
import { default as log } from "../util/log.js"; 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 = []; let collectors = [];
const whitelist = ["440163494529073152", "436321340304392222"]; const whitelist = ["440163494529073152", "436321340304392222"];
@ -62,56 +11,49 @@ export default {
description: "creates reaction role, requires whitelist", description: "creates reaction role, requires whitelist",
arguments: "emoji, user", arguments: "emoji, user",
execute(message, args) { execute(message, args) {
if (whitelist.includes(message.author.id)) { (async () => {
let emojis = getEmojis(message); if (whitelist.includes(message.author.id)) {
let emoji = emojis[0]; let emoji = args[0];
let role = message.mentions.roles.first(); let role = message.mentions.roles.first();
if (!role) { if (!role) {
log("failed.log", message, __filename, `role variable missing`); log("failed.log", message, __filename, `role variable missing`);
return; 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");
}
}, },
}; };

View file

@ -1,15 +1,8 @@
import { default as log } from "../util/log.js"; import { default as log } from "../util/log.js";
import * as dotenv from "dotenv"; import * as action from "../util/discordAction.js";
dotenv.config();
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
function delay(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
export default { export default {
name: "dmuser", name: "dmuser",
description: "forces bot to dm a user something (this will ghost ping them)", description: "forces bot to dm a user something (this will ghost ping them)",
@ -19,22 +12,23 @@ export default {
const guild = message.guild; const guild = message.guild;
if (!user) { if (!user) {
return; user = args[0];
if (!user) {
return;
}
} }
const msgnoprefix = message.content.slice( const msgnoprefix = message.content.slice(
prefix.length + this.name.length + user.id.length + 4 prefix.length + this.name.length + user.id.length + 4
); );
console.log(typeof user);
console.log(user.username);
const msg = msgnoprefix.slice(0, 2000); const msg = msgnoprefix.slice(0, 2000);
let ableToSend = true; let ableToSend = true;
if (msg !== "") { if (msg !== "") {
user.send(msg).catch(() => { 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` `${message.author}, cannot send message to ${user}, this is usually caused by them not being inside the server`
); );
log( log(
@ -45,9 +39,7 @@ export default {
); );
ableToSend = false; ableToSend = false;
}); });
if (message.deletable) { action.messageDelete(message);
message.delete();
}
if (ableToSend) { if (ableToSend) {
log( log(
"forcesay.log", "forcesay.log",

View file

@ -1,6 +1,5 @@
import fs from "fs"; import fs from "fs";
import * as dotenv from "dotenv"; import * as action from "../util/discordAction.js";
dotenv.config();
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
@ -12,19 +11,19 @@ export default {
const msgnoprefix = message.content.slice(prefix.length + this.name.length); const msgnoprefix = message.content.slice(prefix.length + this.name.length);
const name = msgnoprefix.slice(0, 2000); const name = msgnoprefix.slice(0, 2000);
const jsonstring = fs.readFileSync("../pepperbot/data/eulogies.json"); const jsonstring = fs.readFileSync("../pepperbot/data/eulogies.json");
const parsedeulogies = JSON.parse(jsonstring); const parsedEulogies = JSON.parse(jsonstring);
const maxRan = parsedeulogies.eulogies.length; const maxRan = parsedEulogies.eulogies.length;
const randomnum = Math.floor(Math.random() * maxRan); const randomnum = Math.floor(Math.random() * maxRan);
const eulogy = parsedeulogies.eulogies[randomnum]; const eulogy = parsedEulogies.eulogies[randomnum];
if (name.replaceAll(" ", "") === "") { if (name.replaceAll(" ", "") === "") {
message.reply("no name supplied"); action.reply(message, "no name supplied");
return; return;
} }
const parsedeulogy = eulogy.replaceAll("##NAME", name); const replacedEulogy = eulogy.replaceAll("##NAME", name);
message.reply(parsedeulogy); action.reply(message, replacedEulogy);
}, },
}; };

View file

@ -1,8 +1,10 @@
import * as action from "../util/discordAction.js";
export default { export default {
name: "git", name: "git",
description: "posts open pepper repo", description: "posts open pepper repo",
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
message.reply("https://git.reidlab.online/ayeuhugyu/PepperBot"); action.reply(message, "https://git.reidlab.online/ayeuhugyu/PepperBot");
}, },
}; };

View file

@ -1,3 +1,5 @@
import * as action from "../util/discordAction.js";
export default { export default {
name: "guildmembers", name: "guildmembers",
description: description:
@ -5,7 +7,7 @@ export default {
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
const path = `../pepperbot/data/guildmembers.log`; const path = `../pepperbot/data/guildmembers.log`;
message.channel.send({ action.sendMessage(message.channelId, {
files: [ files: [
{ {
attachment: path, attachment: path,

View file

@ -1,6 +1,5 @@
import { joinVoiceChannel } from "@discordjs/voice"; import { joinVoiceChannel } from "@discordjs/voice";
import * as dotenv from "dotenv"; import * as action from "../util/discordAction.js";
dotenv.config();
const guildId = process.env.GUILD_ID; const guildId = process.env.GUILD_ID;
@ -18,9 +17,9 @@ export default {
adapterCreator: voiceState.guild.voiceAdapterCreator, adapterCreator: voiceState.guild.voiceAdapterCreator,
}); });
message.reply(`connected to <#${voiceState.channelId}>`); action.reply(message, `connected to <#${voiceState.channelId}>`);
} else { } else {
message.reply("u aint connected to a voice channel blud 😂😂😂"); action.reply(message, "u aint connected to a voice channel blud 😂😂😂");
} }
}, },
}; };

View file

@ -1,4 +1,5 @@
import { getVoiceConnection } from "@discordjs/voice"; import { getVoiceConnection } from "@discordjs/voice";
import * as action from "../util/discordAction.js";
export default { export default {
name: "leavevc", name: "leavevc",
@ -8,9 +9,12 @@ export default {
if (getVoiceConnection(message.guild.id)) { if (getVoiceConnection(message.guild.id)) {
const connection = getVoiceConnection(message.guild.id); const connection = getVoiceConnection(message.guild.id);
connection.destroy(); connection.destroy();
message.reply(`left voice channel <#${connection.joinConfig.channelId}>`); action.reply(
message,
`left voice channel <#${connection.joinConfig.channelId}>`
);
} else { } else {
message.reply("im not connected to a voice channel here mf"); action.reply(message, "im not connected to a voice channel here mf");
} }
}, },
}; };

View file

@ -1,22 +1,18 @@
import { EmbedBuilder } from "discord.js"; import * as action from "../util/discordAction.js";
export default { export default {
name: "links", name: "links",
description: 'posts "important" links', description: 'posts "important" links',
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
const embed = new EmbedBuilder(); const embed = action.createEmbed();
embed.setTitle("very imphortance linkers"); embed.setTitle("very imphortance linkers");
embed.setThumbnail(
"https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png"
);
embed.setColor(0xff0000);
embed.setDescription(` embed.setDescription(`
https://reidlab.online https://reidlab.online
https://goop.network -- VERY IMPORTANT!!!! https://goop.network -- VERY IMPORTANT!!!!
pepper.church releasing [TIME] (never (not anytime soon)) pepper.church releasing [TIME] (never (not anytime soon))
`); `);
message.reply({ embeds: [embed] }); action.reply(message, { embeds: [embed] });
}, },
}; };

View file

@ -1,9 +1,12 @@
import * as action from "../util/discordAction.js";
export default { export default {
name: "mymovie", name: "mymovie",
description: "posts my movie", description: "posts my movie",
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
message.reply( action.reply(
message,
"https://cdn.discordapp.com/attachments/755150633191080073/1149158052784775219/My_Movie.mp4" "https://cdn.discordapp.com/attachments/755150633191080073/1149158052784775219/My_Movie.mp4"
); );
}, },

View file

@ -1,4 +1,4 @@
import { EmbedBuilder } from "discord.js"; import * as action from "../util/discordAction.js";
import fs from "fs"; import fs from "fs";
export default { export default {
@ -11,11 +11,10 @@ export default {
const randomnum = Math.floor(Math.random() * maxRan); const randomnum = Math.floor(Math.random() * maxRan);
const embed = new EmbedBuilder(); const embed = action.createEmbed();
embed.setTitle("RANDOM PEPPER!!!"); embed.setTitle("RANDOM PEPPER!!!");
embed.setImage(`attachment://${peppers[randomnum]}`); embed.setImage(`attachment://${peppers[randomnum]}`);
embed.setColor(0xff0000); action.reply(message, {
message.reply({
embeds: [embed], embeds: [embed],
files: [`../pepperbot/resources/peppers/${peppers[randomnum]}`], files: [`../pepperbot/resources/peppers/${peppers[randomnum]}`],
}); });

View file

@ -1,13 +1,8 @@
import { default as log } from "../util/log.js"; import { default as log } from "../util/log.js";
import * as action from "../util/discordAction.js";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
function delay(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
export default { export default {
name: "say", name: "say",
description: "forces bot to say something", description: "forces bot to say something",
@ -18,10 +13,8 @@ export default {
const msg = msgnoprefix.slice(0, 2000); const msg = msgnoprefix.slice(0, 2000);
if (msg !== "") { if (msg !== "") {
message.channel.send(msg); action.sendMessage(message.channelId, msg);
if (message.deletable) { action.messageDelete(message);
message.delete();
}
log( log(
"forcesay.log", "forcesay.log",
message, message,

View file

@ -1,4 +1,5 @@
const ignore = ["console.log"]; const ignore = ["console.log"];
import * as action from "../util/discordAction.js";
import fs from "fs"; import fs from "fs";
export default { export default {
@ -22,13 +23,13 @@ export default {
.readdirSync("../pepperbot/logs/") .readdirSync("../pepperbot/logs/")
.filter((file) => file.endsWith(".log")); .filter((file) => file.endsWith(".log"));
if (!logs.includes(msgnoprefix)) { if (!logs.includes(msgnoprefix)) {
message.reply("invalid log file"); action.reply(message, "invalid log file");
return; return;
} }
if (ignore.includes(msgnoprefix)) return; if (ignore.includes(msgnoprefix)) return;
const path = `../pepperbot/logs/${msgnoprefix}`; const path = `../pepperbot/logs/${msgnoprefix}`;
if (!mobileMode) { if (!mobileMode) {
message.channel.send({ action.sendMessage(message.channelId, {
files: [ files: [
{ {
attachment: path, attachment: path,
@ -39,7 +40,8 @@ export default {
} else { } else {
const filestring = fs.readFileSync(path, "utf8"); const filestring = fs.readFileSync(path, "utf8");
console.log(typeof filestring); console.log(typeof filestring);
message.channel.send( action.sendMessage(
message.channelId,
filestring.slice(filestring.length - 500, filestring.length) filestring.slice(filestring.length - 500, filestring.length)
); );
} }

View file

@ -5,8 +5,7 @@ import {
joinVoiceChannel, joinVoiceChannel,
} from "@discordjs/voice"; } from "@discordjs/voice";
import fs from "fs"; import fs from "fs";
import * as dotenv from "dotenv"; import * as action from "../util/discordAction.js";
dotenv.config();
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
@ -59,7 +58,8 @@ export default {
} }
if (!file && !lsmode && !stopmode) { 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: " + "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 proposedfilename
); );
@ -78,9 +78,10 @@ export default {
adapterCreator: voiceState.guild.voiceAdapterCreator, adapterCreator: voiceState.guild.voiceAdapterCreator,
}); });
message.reply(`connected to <#${voiceState.channelId}>`); action.reply(message, `connected to <#${voiceState.channelId}>`);
} else { } 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!" "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; return;
@ -90,7 +91,7 @@ export default {
connection.subscribe(audioPlayer); connection.subscribe(audioPlayer);
audioPlayer.play(audioResource); audioPlayer.play(audioResource);
} else { } else {
message.channel.send({ action.sendMessage(message.channelId, {
files: [ files: [
{ {
attachment: "resources/soundboard/ls.txt", attachment: "resources/soundboard/ls.txt",

View file

@ -1,14 +1,24 @@
import * as action from "../util/discordAction.js";
export default { export default {
name: "test", name: "test",
description: "test command", description: "test command",
arguments: "all", arguments: "all",
execute(message, args) { execute(message, args) {
let text = (async () => {
"command arguments test \nthis list should include all arguments you included in the command \n"; action.sendMessage(message.channelId, "channel send test");
for (let i = 0; i < args.length; i++) { action.sendMainMessage("main message test");
text += args[i] + "\n"; action.sendError("error test");
} const embed = action.createEmbed();
embed.setTitle("EMBED TITLE");
message.reply(text); 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"
);
})();
}, },
}; };

View file

@ -1,5 +1,7 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
import fs from "fs"; import fs from "fs";
import * as action from "../util/discordAction.js";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
export default { export default {
@ -10,7 +12,7 @@ export default {
let proposedfilename = message.content.slice( let proposedfilename = message.content.slice(
prefix.length + this.name.length + 1 prefix.length + this.name.length + 1
); );
const embed = new EmbedBuilder(); const embed = action.createEmbed();
const images = fs const images = fs
.readdirSync("../pepperbot/resources/vileimagery") .readdirSync("../pepperbot/resources/vileimagery")
.filter((file) => file.endsWith(".png")); .filter((file) => file.endsWith(".png"));
@ -49,12 +51,12 @@ export default {
} }
embed.setColor(0xff0000); embed.setColor(0xff0000);
if (!lsMode) { if (!lsMode) {
message.reply({ action.reply(message, {
embeds: [embed], embeds: [embed],
files: [`../pepperbot/resources/vileimagery/${file}`], files: [`../pepperbot/resources/vileimagery/${file}`],
}); });
} else { } else {
message.channel.send({ action.sendMessage(message.channelId, {
files: [ files: [
{ {
attachment: path, attachment: path,

View file

@ -64,6 +64,8 @@ export default function (message, client) {
`use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`, `use of command: ${command} by: ${message.author.username} (\`${message.author}\`)"`,
true true
); );
commands.get(command).execute(message, args, client); (async () => {
commands.get(command).execute(message, args, client);
})();
} }
} }

View file

@ -2,7 +2,7 @@ import { GatewayIntentBits, Partials, Client } from "discord.js";
import events from "./events/importEvents.js"; import events from "./events/importEvents.js";
import register from "./register-commands.js"; import register from "./register-commands.js";
const client = new Client({ export const client = new Client({
intents: [ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMembers,

View file

@ -27,7 +27,7 @@ async () => {
); );
} }
}; };
console.log(commands); //console.log(commands);
const rest = new REST().setToken(process.env.TOKEN); const rest = new REST().setToken(process.env.TOKEN);

View file

@ -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',
});

View file

@ -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',
});

82
src/util/discordAction.js Normal file
View file

@ -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;
}

View file

@ -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:"
}

View file

@ -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⃣

View file

@ -1 +0,0 @@
module.exports = () => /🅰|🅱|🅾|🅿|🈂|🈷|🌡|🌤|🌥|🌦|🌧|🌨|🌩|🌪|🌫|🌬|🌶|🍽|🎖|🎗|🎙|🎚|🎛|🎞|🎟|🏍|🏎|🏔|🏕|🏖|🏗|🏘|🏙|🏚|🏛|🏜|🏝|🏞|🏟|🏳|🏵|🏷|🐿|👁🗨|👁|📽|🕉|🕊|🕯|🕰|🕳|🕶|🕷|🕸|🕹|🖇|🖊|🖋|🖌|🖍|🖥|🖨|🖱|🖲|🖼|🗂|🗃|🗄|🗑|🗒|🗓|🗜|🗝|🗞|🗡|🗣|🗨|🗯|🗳|🗺|🛋|🛍|🛎|🛏|🛠|🛡|🛢|🛣|🛤|🛥|🛩|🛰|🛳||||||||||||#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\*||||0|||1|2|||3|4|5|6|7|8|9/g;

View file

@ -1,23 +1,17 @@
import fs from "fs"; import fs from "fs";
export default function (file, message, from, msg, noconsole) { export default function (file, message, from, msg) {
fs.appendFileSync( try {
`../pepperbot/logs/${file}`, fs.appendFileSync(
`AT: ${Date()} `../pepperbot/logs/${file}`,
`AT: ${Date()}
SCRIPT: ${from} SCRIPT: ${from}
IN: <#${message.channel.id}>
MESSAGE CONTENT: ${message.content} MESSAGE CONTENT: ${message.content}
ADDITIONAL INFORMATION: ${msg} ADDITIONAL INFORMATION: ${msg}
\n` \n`
);
if (!noconsole) {
console.log(
`AT: ${Date()}
SCRIPT: ${from}
MESSAGE CONTENT: ${message.content}
ADDITIONAL INFORMATION: ${msg}
`
); );
} } catch (err) {}
} }
// TEMPLATE: // TEMPLATE: