mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Did a bunch of refactoring
This commit is contained in:
@@ -35,7 +35,7 @@ exports.GenerateDialogFunction = function(dialogJson) {
|
||||
}
|
||||
|
||||
if (typeof(result) === "undefined") {
|
||||
return "";
|
||||
return dialogJson["noResult"];
|
||||
}
|
||||
|
||||
let counter = 0;
|
||||
@@ -97,76 +97,3 @@ exports.SplitArray = function(arr, chunkSize) {
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
//CheckValidDisplay
|
||||
//client - discord.js client
|
||||
//member - discord.js member OR username
|
||||
//channel - discord.js channel OR channel name
|
||||
//checkRole - check the member's role or not
|
||||
exports.CheckValidDisplay = function(client, member, channel, checkRole) { //See if the bot should display its message
|
||||
//handle member strings
|
||||
if (typeof(member) === "string") {
|
||||
//get the member
|
||||
let user = client.users.find(item => item.username === member || item.id === member);
|
||||
let guild = client.guilds.get(process.env.SANCTUM_ID);
|
||||
member = guild.members.get(user.id);
|
||||
}
|
||||
|
||||
//handle channel strings
|
||||
if (typeof(channel) === "string") {
|
||||
channel = client.channels.find(item => item.name === channel || item.id === channel);
|
||||
}
|
||||
|
||||
switch(client.user.username) {
|
||||
//NOTE: some copy/paste here that could be fixed
|
||||
case process.env.GROUP_A_LEADER_NAME:
|
||||
if (checkRole) {
|
||||
return channel.id == process.env.GROUP_A_CHANNEL_ID && member.roles.has(process.env.GROUP_A_ROLE);
|
||||
} else {
|
||||
return channel.id == process.env.GROUP_A_CHANNEL_ID;
|
||||
}
|
||||
|
||||
case process.env.GROUP_B_LEADER_NAME:
|
||||
if (checkRole) {
|
||||
return channel.id == process.env.GROUP_B_CHANNEL_ID && member.roles.has(process.env.GROUP_B_ROLE);
|
||||
} else {
|
||||
return channel.id == process.env.GROUP_B_CHANNEL_ID;
|
||||
}
|
||||
|
||||
case process.env.GROUP_C_LEADER_NAME:
|
||||
if (checkRole) {
|
||||
return channel.id == process.env.GROUP_C_CHANNEL_ID && member.roles.has(process.env.GROUP_C_ROLE);
|
||||
} else {
|
||||
return channel.id == process.env.GROUP_C_CHANNEL_ID;
|
||||
}
|
||||
|
||||
case process.env.GHOST_NAME: {
|
||||
// JSON
|
||||
let rooms = require('../TextAdv/rooms.json'); //TODO: should this be here?
|
||||
let roomExists = false;
|
||||
|
||||
// Loops for all rooms
|
||||
rooms.rooms.forEach(room => {
|
||||
if (channel.id === rooms[room].channel) {
|
||||
roomExists = true;
|
||||
}
|
||||
});
|
||||
|
||||
//if the given room exists
|
||||
if (roomExists) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//DEBUGGING: test channel
|
||||
if (channel.id == process.env.TEST_CHANNEL_ID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//otherwise
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
//default value: always show messages if not a faction leader
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user