updated all requires to use import instead

This commit is contained in:
ayeuhugyu 2023-09-24 17:17:32 -07:00
parent ba443111c8
commit 7d5d32fec1
25 changed files with 109 additions and 98 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
src/logs src/logs
node_modules/ node_modules/
src/commands/cbrowser.js src/commands/cbrowser.js
src/commands/cbrowser.disabled
data/ data/
logs/ logs/
transfer/ transfer/

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.10 - changed all requires to imports
---
1.9 - added p/eulogy and the capability for command arguments 1.9 - added p/eulogy and the capability for command arguments
1.9.1 - added command argument usage for sendlog (mobile support) 1.9.1 - added command argument usage for sendlog (mobile support)

View file

@ -3,6 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "src/index.js", "main": "src/index.js",
"type": "module",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },

View file

@ -1,5 +1,4 @@
const fs = require("fs"); import fs from "fs";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
function delay(time) { function delay(time) {
@ -10,11 +9,11 @@ function delay(time) {
const whitelist = ["440163494529073152", "611625001950380032"]; const whitelist = ["440163494529073152", "611625001950380032"];
module.exports = { export default {
name: "addguildmember", name: "addguildmember",
description: description:
"manually adds a guild member to the members list, whitelist required", "manually adds a guild member to the members list, whitelist required",
arguments: "none", arguments: "member",
execute(message, args) { execute(message, args) {
if (whitelist.includes(message.author.id)) { if (whitelist.includes(message.author.id)) {
if (message.author.bot) return; if (message.author.bot) return;

View file

@ -1,27 +1,30 @@
const { EmbedBuilder } = require("discord.js"); import { EmbedBuilder } from "discord.js";
const fs = require("fs"); import fs from "fs";
module.exports = {
export default {
name: "commands", name: "commands",
description: "displays commands list", description: "displays commands list",
arguments: "none", arguments: "none",
execute(message, args) { execute(message, args) {
let text = ""; (async () => {
let text = "";
const commandFiles = fs const commandFiles = fs
.readdirSync("src/commands/") .readdirSync("src/commands/")
.filter((file) => file.endsWith(".js")); .filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./${file}`);
text += `p/${command.name} - ${command.description} - command arguments: ${command.arguments}\n \n`;
}
const embed = new EmbedBuilder(); for (const file of commandFiles) {
embed.setTitle("PepperBot Commands"); const command = await import(`./${file}`);
embed.setDescription(text); text += `p/${command.default.name} - ${command.default.description} - command arguments: ${command.default.arguments}\n \n`;
embed.setColor(0xff0000); }
embed.setThumbnail( const embed = new EmbedBuilder();
"https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" embed.setTitle("PepperBot Commands");
); embed.setDescription(text);
message.reply({ embeds: [embed] }); embed.setColor(0xff0000);
embed.setThumbnail(
"https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png"
);
message.reply({ embeds: [embed] });
})();
}, },
}; };

View file

@ -1,7 +1,7 @@
const whitelist = ["440163494529073152"]; const whitelist = ["440163494529073152"];
const fs = require("fs"); import fs from "fs";
module.exports = { export default {
name: "crash", name: "crash",
description: "crashes the bot (throws an error), requires whitelist", description: "crashes the bot (throws an error), requires whitelist",
arguments: "none", arguments: "none",

View file

@ -1,11 +1,11 @@
const { EmbedBuilder } = require("discord.js"); import discord from "discord.js";
const emojiRegex = require("emoji-regex"); //const emojiRegex = require("emoji-regex");
const irregularsRegex = require("../util/irregularsRegex.js"); //const irregularsRegex = require("../util/irregularsRegex.js");
const irregulars = require("../util/irregulars.json"); //const irregulars = require("../util/irregulars.json");
const fs = require("fs"); import fs from "fs";
const log = require("../util/log.js").execute; import { default as log } from "../util/log.js";
const getEmojis = (message) => { /*const getEmojis = (message) => {
const { content } = message; const { content } = message;
const result = []; const result = [];
// Normal emojis // Normal emojis
@ -51,13 +51,13 @@ const getEmojis = (message) => {
}); });
} }
return result; return result;
}; };*/
let collectors = []; let collectors = [];
const whitelist = ["440163494529073152", "436321340304392222"]; const whitelist = ["440163494529073152", "436321340304392222"];
module.exports = { export default {
name: "createreactionrole", name: "createreactionrole",
description: "creates reaction role, requires whitelist", description: "creates reaction role, requires whitelist",
arguments: "emoji, user", arguments: "emoji, user",
@ -75,7 +75,7 @@ module.exports = {
return; return;
} }
const embed = new EmbedBuilder(); const embed = new discord.EmbedBuilder();
embed.setThumbnail( embed.setThumbnail(
"https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png" "https://cdn.discordapp.com/attachments/755150633191080073/1149152214850469908/Map_Icon.png"

View file

@ -1,4 +1,6 @@
const log = require("../util/log.js").execute; import { default as log } from "../util/log.js";
import * as dotenv from "dotenv";
dotenv.config();
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
@ -8,7 +10,7 @@ function delay(time) {
}); });
} }
module.exports = { 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)",
arguments: "user, message", arguments: "user, message",
@ -38,7 +40,7 @@ module.exports = {
log( log(
"forcesay.log", "forcesay.log",
message, message,
__filename, import.meta.url,
`${message.author.username} (${message.author}) attempted to force bot to dm ${user} "${msg}"` `${message.author.username} (${message.author}) attempted to force bot to dm ${user} "${msg}"`
); );
ableToSend = false; ableToSend = false;
@ -50,7 +52,7 @@ module.exports = {
log( log(
"forcesay.log", "forcesay.log",
message, message,
__filename, import.meta.url,
`${message.author.username} (${message.author}) forced bot to dm ${user.username} (${user}) "${msg}"` `${message.author.username} (${message.author}) forced bot to dm ${user.username} (${user}) "${msg}"`
); );
} }

View file

@ -1,9 +1,10 @@
const fs = require("fs"); import fs from "fs";
require("dotenv").config(); import * as dotenv from "dotenv";
dotenv.config();
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
module.exports = { export default {
name: "eulogy", name: "eulogy",
description: "generates a eulogy", description: "generates a eulogy",
arguments: "name", arguments: "name",

View file

@ -1,4 +1,4 @@
module.exports = { export default {
name: "guildmembers", name: "guildmembers",
description: description:
"sends a file including all past guild members (may not be accurrate, is mostly manually updated) -- note: also includes allies", "sends a file including all past guild members (may not be accurrate, is mostly manually updated) -- note: also includes allies",

View file

@ -1,5 +1,5 @@
const { EmbedBuilder } = require("discord.js"); import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: "links", name: "links",
description: 'posts "important" links', description: 'posts "important" links',
arguments: "none", arguments: "none",

View file

@ -1,4 +1,4 @@
module.exports = { export default {
name: "mymovie", name: "mymovie",
description: "posts my movie", description: "posts my movie",
arguments: "none", arguments: "none",

View file

@ -1,4 +1,4 @@
module.exports = { export default {
name: "openpepper", name: "openpepper",
description: "posts open pepper repo", description: "posts open pepper repo",
arguments: "none", arguments: "none",

View file

@ -1,7 +1,7 @@
const { EmbedBuilder } = require("discord.js"); import { EmbedBuilder } from "discord.js";
const fs = require("fs"); import fs from "fs";
module.exports = { export default {
name: "pepper", name: "pepper",
description: "RPG (random pepper generator)", description: "RPG (random pepper generator)",
arguments: "none", arguments: "none",

View file

@ -1,4 +1,4 @@
const log = require("../util/log.js").execute; import { default as log } from "../util/log.js";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
@ -8,7 +8,7 @@ function delay(time) {
}); });
} }
module.exports = { export default {
name: "say", name: "say",
description: "forces bot to say something", description: "forces bot to say something",
arguments: "message", arguments: "message",
@ -25,7 +25,7 @@ module.exports = {
log( log(
"forcesay.log", "forcesay.log",
message, message,
__filename, import.meta.url,
`${message.author.username} (${message.author}) forced bot to say "${msg}"` `${message.author.username} (${message.author}) forced bot to say "${msg}"`
); );
} }

View file

@ -1,10 +1,7 @@
const { Options } = require("discord.js");
const { Collection } = require("discord.js");
const prefix = process.env.PREFIX;
const ignore = ["console.log"]; const ignore = ["console.log"];
const fs = require("fs"); import fs from "fs";
module.exports = { export default {
name: "sendlog", name: "sendlog",
description: "sends log file (if the file is valid)", description: "sends log file (if the file is valid)",
arguments: "m, mobile", arguments: "m, mobile",

View file

@ -1,6 +1,4 @@
const log = require("../util/log.js").execute; export default {
module.exports = {
name: "test", name: "test",
description: "test command", description: "test command",
arguments: "all", arguments: "all",

View file

@ -1,8 +1,8 @@
const { EmbedBuilder } = require("discord.js"); import { EmbedBuilder } from "discord.js";
const fs = require("fs"); import fs from "fs";
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
module.exports = { export default {
name: "vileimagery", name: "vileimagery",
description: "Do NOT run.", description: "Do NOT run.",
arguments: "file name", arguments: "file name",

View file

@ -1,6 +1,6 @@
const fs = require("fs"); import fs from "fs";
module.exports.execute = function (member, client) { export default function (member, client) {
if (member.guild.id === "1112819622505365556") { if (member.guild.id === "1112819622505365556") {
fs.appendFileSync( fs.appendFileSync(
"../pepperbot/data/guildmembers.log", "../pepperbot/data/guildmembers.log",
@ -11,4 +11,4 @@ module.exports.execute = function (member, client) {
`added new guild member ${member.user.username} (${member.user.id}) to members list` `added new guild member ${member.user.username} (${member.user.id}) to members list`
); );
} }
}; }

View file

@ -1,6 +1,13 @@
module.exports = { import { default as guildMemberAdd } from "./guildMemberAdd.js";
guildMemberAdd: require("./guildMemberAdd.js").execute, import { default as messageCreate } from "./messageCreate.js";
messageCreate: require("./messageCreate.js").execute, import { default as messageDelete } from "./messageDelete.js";
messageDelete: require("./messageDelete.js").execute, import { default as ready } from "./ready.js";
ready: require("./ready.js").execute,
const events = {
guildMemberAdd,
messageCreate,
messageDelete,
ready,
}; };
export default events;

View file

@ -1,9 +1,10 @@
require("dotenv").config(); import * as dotenv from "dotenv";
const log = require("../util/log.js").execute; dotenv.config();
const fs = require("fs"); import { default as log } from "../util/log.js";
const discord = require("discord.js"); import fs from "fs";
import discord from "discord.js";
commands = new discord.Collection(); let commands = new discord.Collection();
const commandFiles = fs const commandFiles = fs
.readdirSync("src/commands/") .readdirSync("src/commands/")
@ -27,12 +28,12 @@ function parseargs(string) {
const prefix = process.env.PREFIX; const prefix = process.env.PREFIX;
module.exports.execute = function (message, client) { export default function (message, client) {
if (message.channel.type === 1) { if (message.channel.type === 1) {
log( log(
"directmessages.log", "directmessages.log",
message, message,
__filename, import.meta.url,
`direct message from ${message.author.username} (${message.author}) with: "${message.content}"` `direct message from ${message.author.username} (${message.author}) with: "${message.content}"`
); );
} }
@ -50,7 +51,7 @@ module.exports.execute = function (message, client) {
log( log(
"failed.log", "failed.log",
message, message,
__filename, import.meta.url,
`attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"` `attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"`
); );
} }
@ -59,10 +60,10 @@ module.exports.execute = function (message, client) {
log( log(
"commands.log", "commands.log",
message, message,
__filename, import.meta.url,
`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); commands.get(command).execute(message, args, client);
} }
}; }

View file

@ -1,10 +1,11 @@
const log = require("../util/log.js").execute; import { default as log } from "../util/log.js";
module.exports.execute = function (message) { export default function (message) {
log( log(
"deletedmessages.log", "deletedmessages.log",
message, message,
__filename, import.meta.url,
`deleted message from ${message.author.username} (${message.author}) with: "${message.content}"` `deleted message from ${message.author.username} (${message.author}) with: "${message.content}"`,
true
); );
}; }

View file

@ -1,7 +1,5 @@
const log = require("../util/log.js").execute; export default function (client) {
module.exports.execute = function (client) {
console.log(`${client.user.tag} is online.`); console.log(`${client.user.tag} is online.`);
const channel = client.channels.cache.get("1148814162273763418"); const channel = client.channels.cache.get("1148814162273763418");
channel.send("pepperbot restart complete"); channel.send("pepperbot restart complete");
}; }

View file

@ -1,7 +1,5 @@
require("dotenv").config(); import { GatewayIntentBits, Partials, Client } from "discord.js";
const { Client, GatewayIntentBits, Partials } = require("discord.js"); import events from "./events/importEvents.js";
const events = require("./events/importEvents.js");
const client = new Client({ const client = new Client({
intents: [ intents: [

View file

@ -1,6 +1,6 @@
const fs = require("fs"); import fs from "fs";
module.exports.execute = function (file, message, from, msg, noconsole) { export default function (file, message, from, msg, noconsole) {
fs.appendFileSync( fs.appendFileSync(
`../pepperbot/logs/${file}`, `../pepperbot/logs/${file}`,
`AT: ${Date()} `AT: ${Date()}
@ -18,7 +18,7 @@ ADDITIONAL INFORMATION: ${msg}
` `
); );
} }
}; }
// TEMPLATE: // TEMPLATE:
// const log = require('../util/log.js').execute() // const log = require('../util/log.js').execute()