Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructuring bot #1

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions commands/aclose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module.exports = {
name: 'aclose',
aliases: false,
level: 'Moderator',
guildOnly: true,
args: true,
usage: '[reason]-[note]',
description: 'Anonymously close a user thread.',
note: false,
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const aclose = param.aclose;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noChannelEmbed = getEmbed.execute(param, config.error_color, "Configuration Needed", "\`categoryID\` and/or \`logChannelID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` and/or \`modRoleID\` value is empty.");
const notChannelEmbed = getEmbed.execute(param, config.error_color, "Invalid Channel", `This isn\'t thread channel.`);

//Yes i know it's nasty to look at that many nested if else but it's needed @,@
if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
return message.channel.send(noServerEmbed);
} else {
if(message.guild.id == config.threadServerID){
//inside thread server
if (config.adminRoleID == "empty" || config.modRoleID == "empty"){
//adminRoleID or modRoleID empty
return message.channel.send(noAdminEmbed);
} else if(config.categoryID == "empty" || config.logChannelID == "empty"){
//categoryID or logChannelID empty
return message.channel.send(noChannelEmbed);
} else {
//adminRoleID, modRoleID, categoryID and logChannelID not empty
if (message.channel.parentID != config.categoryID || message.channel.id == config.logChannelID || message.channel.id == config.botChannelID) {
//the channel isn't under modmail category or it's a log channel or it's bot channel -_-
return message.channel.send(notChannelEmbed);
} else {
//the channel is under modmail category, it's not a log channel, and it's not bot channel
if(message.author.id == config.botOwnerID){
return aclose.execute(param, message, args);
} else if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return aclose.execute(param, message, args);
} else if (await param.roleCheck.execute(message, config.modRoleID)){
//user has moderator role
return aclose.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}

}
}

} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
70 changes: 70 additions & 0 deletions commands/areply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
name: 'areply',
aliases: false,
level: 'Moderator',
guildOnly: true,
args: false,//in case only attachment no message
usage: '[reply message]',
description: 'Anonymously reply to a user thread.',
note: false,
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const areply = param.areply;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noChannelEmbed = getEmbed.execute(param, config.error_color, "Configuration Needed", "\`categoryID\` and/or \`logChannelID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` and/or \`modRoleID\` value is empty.");
const notChannelEmbed = getEmbed.execute(param, config.error_color, "Invalid Channel", `This isn\'t thread channel.`);
const noArgsEmbed = param.getEmbed.execute(param, config.warning_color, "Missing Arguments", `You didn\'t provide any arguments nor attachments.`);

//Yes i know it's nasty to look at that many nested if else but it's needed @,@
if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
return message.channel.send(noServerEmbed);
} else {
if(message.guild.id == config.threadServerID){
//inside thread server
if (config.adminRoleID == "empty" || config.modRoleID == "empty"){
//adminRoleID or modRoleID empty
return message.channel.send(noAdminEmbed);
} else if(config.categoryID == "empty" || config.logChannelID == "empty"){
//categoryID or logChannelID empty
return message.channel.send(noChannelEmbed);
} else {
//adminRoleID, modRoleID, categoryID and logChannelID not empty
if (message.channel.parentID != config.categoryID || message.channel.id == config.logChannelID || message.channel.id == config.botChannelID) {
//the channel isn't under modmail category or it's a log channel or it's bot channel -_-
return message.channel.send(notChannelEmbed);
} else {
//the channel is under modmail category, it's not a log channel, and it's not bot channel
if(!args.length && message.attachments.size == 0){
return message.channel.send(noArgsEmbed);
} else if(message.author.id == config.botOwnerID){
return areply.execute(param, message, args);
} else if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return areply.execute(param, message, args);
} else if (await param.roleCheck.execute(message, config.modRoleID)){
//user has moderator role
return areply.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}

}
}

} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
50 changes: 50 additions & 0 deletions commands/bind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
name: 'bind',
aliases: false,
level: 'Admin',
guildOnly: true,
args: true,
usage: '<userID> <channelID>',
description: 'Bind user thread to a channel.',
note: 'Only use under these circumtances : \n> There is an open thread from other bot.\n> The channel was accidentally deleted.\n> Category channel was accidentally deleted and changed.',
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const bind = param.bind;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` value is empty.");

if (message.author.id === config.botOwnerID) {
//bot owner
return bind.execute(param, message, args);
} else if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
message.channel.send(noServerEmbed);
return bind.execute(param, message, args);
} else {
if(message.guild.id == config.mainServerID || message.guild.id == config.threadServerID){
//inside main server or thread server
if (config.adminRoleID == "empty"){
//adminRoleID empty
message.channel.send(noAdminEmbed);
}
if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return bind.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}
} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
53 changes: 53 additions & 0 deletions commands/block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
name: 'block',
aliases: false,
level: 'Moderator',
guildOnly: true,
args: true,
usage: '<userID> [reason]',
description: 'Block a user from creating new thread and replying to a thread.',
note: 'User presence isn\'t checked to enable blocking users that are outside the server.',
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const block = param.block;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` and/or \`modRoleID\` value is empty.");

if (message.author.id === config.botOwnerID) {
//bot owner
return block.execute(param, message, args);
} else if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
message.channel.send(noServerEmbed);
return block.execute(param, message, args);
} else {
if(message.guild.id == config.mainServerID || message.guild.id == config.threadServerID){
//inside main server or thread server
if (config.adminRoleID == "empty" || config.modRoleID == "empty"){
//adminRoleID empty
message.channel.send(noAdminEmbed);
}
if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return block.execute(param, message, args);
} else if (await param.roleCheck.execute(message, config.modRoleID)){
//user has moderator role
return block.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}
} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
53 changes: 53 additions & 0 deletions commands/blockinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
name: 'blockinfo',
aliases: false,
level: 'Moderator',
guildOnly: true,
args: true,
usage: '<userID>',
description: 'Information about a user\'s block.',
note: false,
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const blockinfo = param.blockinfo;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` and/or \`modRoleID\` value is empty.");

if (message.author.id === config.botOwnerID) {
//bot owner
return blockinfo.execute(param, message, args);
} else if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
message.channel.send(noServerEmbed);
return blockinfo.execute(param, message, args);
} else {
if(message.guild.id == config.mainServerID || message.guild.id == config.threadServerID){
//inside main server or thread server
if (config.adminRoleID == "empty" || config.modRoleID == "empty"){
//adminRoleID empty
message.channel.send(noAdminEmbed);
}
if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return blockinfo.execute(param, message, args);
} else if (await param.roleCheck.execute(message, config.modRoleID)){
//user has moderator role
return blockinfo.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}
} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
53 changes: 53 additions & 0 deletions commands/blocklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
name: 'blocklist',
aliases: false,
level: 'Moderator',
guildOnly: true,
args: false,
usage: '[page number]',
description: 'List of blocked users.',
note: false,
async execute(param, message, args){
const config = param.config;
const getEmbed = param.getEmbed;
const blocklist = param.blocklist;

const noPermEmbed = getEmbed.execute(param, config.warning_color, "Missing Permission", "You don\'t have permission to run this command.");
const noServerEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`mainServerID\` and/or \`threadServerID\` value is empty.");
const noAdminEmbed = getEmbed.execute(param, config.warning_color, "Configuration Needed", "\`adminRoleID\` and/or \`modRoleID\` value is empty.");

if (message.author.id === config.botOwnerID) {
//bot owner
return blocklist.execute(param, message, args);
} else if (config.mainServerID == "empty" && config.threadServerID == "empty" && message.member.hasPermission("ADMINISTRATOR")) {
//mainServerID and threadServerID empty and user has ADMINISTRATOR permission
message.channel.send(noServerEmbed);
return blocklist.execute(param, message, args);
} else {
if(message.guild.id == config.mainServerID || message.guild.id == config.threadServerID){
//inside main server or thread server
if (config.adminRoleID == "empty" || config.modRoleID == "empty"){
//adminRoleID empty
message.channel.send(noAdminEmbed);
}
if (message.member.hasPermission("ADMINISTRATOR") || await param.roleCheck.execute(message, config.adminRoleID)){
//user has ADMINISTRATOR permission or has admin role
return blocklist.execute(param, message, args);
} else if (await param.roleCheck.execute(message, config.modRoleID)){
//user has moderator role
return blocklist.execute(param, message, args);
} else {
//user didn't have ADMINISTRATOR permission nor has admin role
if (config.botChannelID != "empty" && message.channel.id != config.botChannelID) {
return;
} else {
return message.channel.send(noPermEmbed);
};
}
} else {
//outside main server and thread server
return message.channel.send(noPermEmbed);
}
};
}
};
Loading