Added missing role and channel check
This commit is contained in:
1 parent
a82101ab30
commit
ef83832819
1 file changed
+60
-1
+60
-1
@@ -14,7 +14,7 @@ const panelconfig = yaml.load(
|
|||||||
|
|
||||||
const Event = require("../Structures/Event.js");
|
const Event = require("../Structures/Event.js");
|
||||||
|
|
||||||
module.exports = new Event("ready", (client) => {
|
module.exports = new Event("ready", async (client) => {
|
||||||
client.user.setActivity(supportbot.BotActivity, {
|
client.user.setActivity(supportbot.BotActivity, {
|
||||||
type: supportbot.ActivityType,
|
type: supportbot.ActivityType,
|
||||||
url: supportbot.StreamingURL,
|
url: supportbot.StreamingURL,
|
||||||
@@ -65,7 +65,66 @@ module.exports = new Event("ready", (client) => {
|
|||||||
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`);
|
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`);
|
||||||
console.log(` `);
|
console.log(` `);
|
||||||
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
|
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`);
|
||||||
|
if (
|
||||||
|
!supportbot.Guild ||
|
||||||
|
(await client.guilds.cache.size) !== 1 ||
|
||||||
|
(await client.guilds.cache.first().id) !== supportbot.Guild
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
`\u001b[31m`,
|
||||||
|
`${client.user.username} is not in the correct server set in your config. Please join the server and restart the bot.`
|
||||||
|
);
|
||||||
|
console.log(`\u001b[31m`, `${client.user.username} will now exit.`);
|
||||||
|
return process.exit(1);
|
||||||
|
}
|
||||||
|
const roles = [
|
||||||
|
supportbot.Admin,
|
||||||
|
supportbot.Staff,
|
||||||
|
supportbot.TicketBlackListRole,
|
||||||
|
supportbot.DepartmentRole_1,
|
||||||
|
supportbot.DepartmentRole_2,
|
||||||
|
supportbot.DepartmentRole_3,
|
||||||
|
];
|
||||||
|
if (supportbot.AutoRole) roles.push(supportbot.AutoRole_Role);
|
||||||
|
const channels = [
|
||||||
|
supportbot.SuggestionChannel,
|
||||||
|
supportbot.TicketLog,
|
||||||
|
supportbot.TranscriptLog,
|
||||||
|
panelconfig.Channel,
|
||||||
|
];
|
||||||
|
const missingR = [];
|
||||||
|
const missingC = [];
|
||||||
|
|
||||||
|
for (let c of channels) {
|
||||||
|
const find = await client.channels.cache.find(
|
||||||
|
(channel) => channel.name === c || channel.id === c
|
||||||
|
);
|
||||||
|
if (!find) missingC.push(c);
|
||||||
|
}
|
||||||
|
for (let r of roles) {
|
||||||
|
const find = await client.guilds.cache
|
||||||
|
.first()
|
||||||
|
.roles.cache.find((role) => role.name === r || role.id === r);
|
||||||
|
if (!find) missingR.push(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missingR.length > 0) {
|
||||||
|
console.log(
|
||||||
|
"\u001b[33m",
|
||||||
|
`[WARN] The following Roles could not be found! Please check your configs!\n${missingR.join(
|
||||||
|
", "
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missingC.length > 0) {
|
||||||
|
console.log(
|
||||||
|
"\u001b[33m",
|
||||||
|
`[WARN] The following Channels could not be found! Please check your configs!\n${missingC.join(
|
||||||
|
", "
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
if (panelconfig.TicketPanel) {
|
if (panelconfig.TicketPanel) {
|
||||||
let chan1 = client.channels.cache.find(
|
let chan1 = client.channels.cache.find(
|
||||||
(channel) => channel.name === panelconfig.Channel
|
(channel) => channel.name === panelconfig.Channel
|
||||||
|
|||||||
Reference in new issue
Block a user