This commit is contained in:
17
index.js
17
index.js
@ -19,6 +19,7 @@ const client = new Client({
|
||||
],
|
||||
});
|
||||
client.commands = new Collection();
|
||||
client.ownerID = 263247134147608578;
|
||||
|
||||
fs.readdir("./commands/", (err, files) => {
|
||||
if (err) return console.error(err);
|
||||
@ -32,12 +33,12 @@ fs.readdir("./commands/", (err, files) => {
|
||||
});
|
||||
|
||||
const url = "https://drive.overflow.fun/public/react.json";
|
||||
let userstoreact = [];
|
||||
client.usersToReactTo = [];
|
||||
client.once(Events.ClientReady, async (readyClient) => {
|
||||
const res = await fetch(url);
|
||||
const data = await res.json();
|
||||
|
||||
userstoreact = data.map((entry) => {
|
||||
client.usersToReactTo = data.map((entry) => {
|
||||
const [userId, emoji] = entry.split(":");
|
||||
return { userId, emoji };
|
||||
});
|
||||
@ -46,12 +47,14 @@ client.once(Events.ClientReady, async (readyClient) => {
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
if (message.author.bot) return;
|
||||
console.log(message.mentions.users);
|
||||
|
||||
userstoreact.forEach(async (usr) => {
|
||||
if (message.mentions.users.find((u) => u.id == usr.userId)) {
|
||||
client.usersToReactTo.forEach(async (item) => {
|
||||
if (
|
||||
message.mentions.users.find((u) => u.id == item.userId) &&
|
||||
!message.reference
|
||||
) {
|
||||
try {
|
||||
await message.react(usr.emoji);
|
||||
await message.react(item.emoji);
|
||||
} catch (err) {
|
||||
console.error("Failed to react to message:", err);
|
||||
}
|
||||
@ -67,7 +70,7 @@ client.on(Events.MessageCreate, async (message) => {
|
||||
|
||||
if (!cmd) return;
|
||||
|
||||
cmd.run(client, message, args);
|
||||
await cmd.run(client, message, args);
|
||||
});
|
||||
|
||||
// Log in to Discord with your client's token
|
||||
|
Reference in New Issue
Block a user