Files
SupportBot/Events/ready.js
T

202 lines
6.2 KiB
JavaScript
Raw Permalink Normal View History

2021-10-24 22:47:42 +01:00
// SupportBot | Emerald Services
// Ready Event
const fs = require("fs");
const Discord = require("discord.js");
2024-06-12 12:54:31 +01:00
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
const client = new Discord.Client({intents: 32767})
2021-10-24 22:47:42 +01:00
const yaml = require("js-yaml");
2022-08-12 01:35:36 +01:00
2021-10-27 19:30:10 -05:00
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
2021-10-24 22:47:42 +01:00
const panelconfig = yaml.load(
2021-10-27 19:30:10 -05:00
fs.readFileSync("./Configs/ticket-panel.yml", "utf8")
2021-10-24 22:47:42 +01:00
);
2022-08-12 01:35:36 +01:00
const cmdconfig = yaml.load(
fs.readFileSync("./Configs/commands.yml", "utf8")
);
const msgconfig = yaml.load(
fs.readFileSync("./Configs/messages.yml", "utf8")
);
2021-10-24 22:47:42 +01:00
const Event = require("../Structures/Event.js");
2024-06-12 12:54:31 +01:00
let chan1 = client.channels.cache.get(panelconfig.Channel);
2022-02-27 04:30:15 +00:00
module.exports = new Event("ready", async (client, interaction) => {
const { getRole, getChannel, getCategory } = client;
2024-06-12 12:54:31 +01:00
if (supportbot.Activity.Type === "Playing", "playing") {
client.user.setPresence({
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Playing }],
status: supportbot.Activity.Type,
});
}
if (supportbot.Activity.Type === "Watching", "watching") {
client.user.setPresence({
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Watching }],
status: supportbot.Activity.Type,
});
}
if (supportbot.Activity.Type === "Listening", "listening") {
client.user.setPresence({
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Listening }],
status: supportbot.Activity.Type,
});
}
if (supportbot.Activity.Type === "Competing", "competing") {
client.user.setPresence({
activities: [{ name: supportbot.Activity.Status, type: Discord.ActivityType.Competing }],
status: supportbot.Activity.Type,
});
}
2021-10-24 22:47:42 +01:00
2022-07-22 13:19:05 +01:00
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
console.log(` `);
console.log(`\u001b[31m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`);
console.log(`\u001b[31m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`);
console.log(`\u001b[31m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`);
console.log(`\u001b[31m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`);
console.log(`\u001b[31m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`);
console.log(`\u001b[31m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`);
console.log(`\u001b[31m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`);
console.log(`\u001b[31m`, `╋╋╋╋╋╋╋┗┛╋┗┛`);
2021-10-24 22:47:42 +01:00
console.log(` `);
2022-06-28 03:14:54 +01:00
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
2021-10-24 22:47:42 +01:00
console.log(` `);
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
`${supportbot.General.Name} | [${supportbot.SupportBot_Version}]`,
`\u001b[32m`,
`Connected to Discord`,
2021-10-24 22:47:42 +01:00
);
2022-07-22 13:19:05 +01:00
console.log(`\u001b[31m`, `SupportBot proudly created by Emerald Development`);
console.log(` `);
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
`Discord`,
`\u001b[32m`,
`https://dsc.gg/emerald-dev`,
);
2022-07-22 13:19:05 +01:00
2021-10-24 22:47:42 +01:00
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
2024-06-12 12:54:31 +01:00
`Website`,
2022-07-22 13:19:05 +01:00
`\u001b[32m`,
2024-06-12 12:54:31 +01:00
`https://emeraldsrv.com`,
2021-10-24 22:47:42 +01:00
);
2022-07-22 13:19:05 +01:00
2021-10-24 22:47:42 +01:00
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
2024-06-12 12:54:31 +01:00
`Marketplace`,
2022-07-22 13:19:05 +01:00
`\u001b[32m`,
2024-06-12 12:54:31 +01:00
`https://market.emeraldsrv.com`,
2021-10-24 22:47:42 +01:00
);
2022-07-22 13:19:05 +01:00
2021-10-24 22:47:42 +01:00
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
2024-06-12 12:54:31 +01:00
`Documentation`,
2022-07-22 13:19:05 +01:00
`\u001b[32m`,
2024-06-12 12:54:31 +01:00
`https://emeraldsrv.com/third-party`,
2021-10-24 22:47:42 +01:00
);
2022-07-22 13:19:05 +01:00
console.log(` `);
2021-10-24 22:47:42 +01:00
console.log(
2022-07-22 13:19:05 +01:00
`\u001b[31m`,
`Invite URL:`,
2021-10-24 22:47:42 +01:00
`\u001b[36m`,
2022-07-22 13:19:05 +01:00
`https://discord.com/api/oauth2/authorize?client_id=` +
client.user.id +
`&permissions=8&scope=bot%20applications.commands`
2021-10-24 22:47:42 +01:00
);
2022-06-16 22:12:14 +01:00
2022-07-22 13:19:05 +01:00
console.log(` `);
console.log(`\u001b[32m`, `――――――――――――――――――――――――――――――――――――――――――――`);
2022-06-16 22:12:14 +01:00
2021-11-17 19:04:20 -06:00
const roles = [
2022-08-12 01:35:36 +01:00
supportbot.Roles.StaffMember.Admin,
supportbot.Roles.StaffMember.Staff,
supportbot.Roles.ModRoles.Blacklisted,
supportbot.Roles.ModRoles.Muted
2021-11-17 19:04:20 -06:00
];
2022-06-23 00:05:08 +01:00
2022-02-11 23:34:38 -06:00
supportbot.Departments.forEach((department) => roles.push(department.role));
2022-06-23 00:05:08 +01:00
2022-08-12 01:35:36 +01:00
if (supportbot.Roles.AutoRole.Role) roles.push(supportbot.Roles.AutoRole.Role);
2024-06-12 12:54:31 +01:00
const channels = [
supportbot.Suggestions.Channel,
supportbot.Ticket.Log.TicketLog,
supportbot.Ticket.Log.TranscriptLog,
panelconfig.Channel,
supportbot.Welcome.Channel,
supportbot.Leave.Channel,
supportbot.Translate.Log
];
2022-06-22 23:30:59 +01:00
//const categories = [supportbot.TicketCategory];
2021-11-17 19:04:20 -06:00
2024-06-12 12:54:31 +01:00
if (!channels) {
console.log("\u001b[31m", `[MISSING CHANNEL]`, `\u001b[37;1m`, `${channels}`, "\u001b[31m", `channel not found. Please check your config file.`);
return;
}
// else {
// console.log(`\u001b[32m`, `[CHANNEL LOCATED]`, `\u001b[37;1m`, `${channels}`, `\u001b[32;1m`, `channel has been found.`);
// }
const missingC = [];
const missingR = [];
const missingCat = [];
2022-07-23 07:50:12 +01:00
2021-11-17 19:04:20 -06:00
for (let r of roles) {
const find = await getRole(r, client.guilds.cache.first());
2021-11-17 19:04:20 -06:00
if (!find) missingR.push(r);
}
2022-06-22 23:30:59 +01:00
// for (let cat of categories) {
// const find = await getCategory(cat, client.guilds.cache.first());
// if (!find) missingCat.push(cat);
// }
2021-10-24 22:47:42 +01:00
2021-11-17 19:04:20 -06:00
if (missingR.length > 0) {
console.log(
2022-07-22 13:19:05 +01:00
"\u001b[31m",
`[MISSING CONFIGURATION]`,
2021-11-17 19:04:20 -06:00
"\u001b[33m",
2022-07-22 13:19:05 +01:00
`The following Roles could not be found in your server.\n`, `\u001b[31m`, `[${missingR.join(
2021-11-17 19:04:20 -06:00
", "
2022-07-22 13:19:05 +01:00
)}]`, `\n `,
2021-11-17 19:04:20 -06:00
);
}
if (missingC.length > 0) {
console.log(
2022-07-22 13:19:05 +01:00
"\u001b[31m",
`[MISSING CONFIGURATION]`,
2021-11-17 19:04:20 -06:00
"\u001b[33m",
2022-07-22 13:19:05 +01:00
`The following Channels could not be found in your server.\n`, `\u001b[31m`, `[${missingC.join(
2021-11-17 19:04:20 -06:00
", "
2022-07-22 13:19:05 +01:00
)}]`, `\n `
2021-11-17 19:04:20 -06:00
);
}
if (missingCat.length > 0) {
console.log(
2022-07-22 13:19:05 +01:00
"\u001b[31m",
`[MISSING CONFIGURATION]`,
"\u001b[33m",
2022-07-22 13:19:05 +01:00
`The following Categories could not be found in your server.\n`, `\u001b[31m`, `[${missingCat.join(
", "
2022-07-22 13:19:05 +01:00
)}]`, `\n `,
);
}
2022-06-23 00:05:08 +01:00
});