Compare commits

...

11 Commits

Author SHA1 Message Date
rhearmas 2c862b1c15 We finally have it finished, for now 2020-08-20 18:02:20 -04:00
rhearmas 2434b76b31 Add rfa.js 2020-08-15 07:45:54 -04:00
rhearmas b764bc7667 Add rfa, update some more stuff 2020-08-15 07:45:36 -04:00
rhearmas 8d92e7d176 Ignore files starting with underscores 2020-08-11 22:06:15 -04:00
rhearmas 240b60076a Progress! 2020-02-13 15:38:39 -05:00
rhearmas e1ecadfc8e Preparing to make the huge overhaul 2020-02-09 21:27:26 -05:00
rhearmas d8df28edbc Fix some stuff 2020-02-09 21:09:12 -05:00
rhearmas 12fc7ad8b4 Add mine and usable systems 2020-02-09 21:08:19 -05:00
Carol Knieriem c9f87cecbd
adjust colon 2020-02-07 12:49:04 -05:00
User 6068ee89e3 Added ability to view only commands you have access to 2020-02-07 09:46:42 -05:00
rhearmas d8fbddb351 adding specific command info, attempting to create all commands 2020-02-06 16:07:08 -05:00
6 changed files with 386 additions and 108 deletions

View File

@ -20,8 +20,12 @@ exports.run = async (client, message, args) => {
let fetched;
fetched = await chnl.fetchMessages();
await output.edit(`Clearing messages in ${chnl}.`);
chnl.bulkDelete(fetched);
await output.edit(`Messages cleared in ${chnl}.`);
if(fetched) {
chnl.bulkDelete(fetched);
await output.edit(`Messages cleared in ${chnl}.`);
} else {
await output.edit(`No messages found in ${chnl}.`);
}
}
clearLanding();
@ -29,33 +33,27 @@ exports.run = async (client, message, args) => {
.setTitle("Introduction")
.setColor(0x2f3136)
.setDescription(`Welcome to **${guild.name}**! This is a Discord server that I personally run for all my shenanigans. This is the channel where I explain rules and stuff and other stuff.`)
.addField("IMPORTANT DISCLAIMER:", "This list does not constitute the full list of rules. With that in mind, try to use common sense and good judgement for any action you're about to take at all times.")
.addField("Before we go further...","I don't care if you use profanity here, since Discord only allows users who are at least 13 years of age. If you have a problem with this, then this isn't the discord server for you.")
.addField("Before we jump in...", "This list does not constitute the full list of rules. With that in mind, try to use common sense and good judgement for any action you're about to take at all times.\nDiscord's [Community Guidelines](https://discord.com/channels/387727726297088002/743142164564803705) also have some important rules not mentioned here.")
.setThumbnail(guild.iconURL);
const textrules = new Discord.RichEmbed()
.setTitle("Text Channel Rules")
.setColor(0x2f3136)
.addField("Use common sense.","This means that you shouldn't be a jerk to others.")
.addField("No raiding.","Nobody here endorses raiding. Raiding this server or trying to rally other users to help you raid this server or another server is not allowed.")
.addField("Do not attempt to destroy the server.","This includes vandalizing non-spam channels with spam or playing excessively loud music.")
.addField("Abide by Discord's global ruleset.","This means that you should take the time to read the [Discord Terms of Service](https://discordapp.com/terms) and [Community Guidelines](https://discordapp.com/guidelines).")
.addField("Do not attempt to destroy the server.","For example, don't vandalize media channels with spam or try to check your level in the general chat.")
.addField("No discrimination.","This includes disrespecting people because of personal factors such as gender, sexual orientation, mental disabilities, race, age, location of residence, or anything else of the like.")
.addField("Threats towards others are not allowed.","Do not attempt to cause others to feel endangered in this server. We want to provide a safe space for everyone here, so don't ruin it.")
.addField("Abide by Discord's global platform rules.","This means that you should take the time to read the [Discord Terms of Service](https://discordapp.com/terms) and [Community Guidelines](https://discordapp.com/guidelines).")
.addField("Don't complain about your punishments.","They were given for a valid reason. ModMail exists just in case a staff member falsely punishes you.")
.addField("Loopholes aren't a thing, so don't go looking for them.","Don't be a wise-ass and just follow the rules. Don't test your boundaries, being here is a priviledge, not a right.")
.addField("Advertising outside of the advertisement channel is not permitted.","This includes third-party services (that are not related to this Discord) or anything you or others have created, regardless of permission granted. Advertising other Discord servers -- or advertising **anything** in your playing status or through unsolicited DMs -- is strictly forbidden.")
.addField("Loopholes aren't a thing, so don't go looking for them.","Don't be a wise-a## and just follow the rules. Don't test your boundaries; being here is a priviledge, not a right.")
.addField("Advertising outside of the advertisement channel is not permitted.","Things such third-party services that are not related to this Discord or anything you or others have created arne't allowed. Advertising other Discord servers -- or advertising **anything** in your playing status or through unsolicited DMs -- is strictly forbidden.")
.addField("Don't cause beef with other members.","Don't send hate to other people if you see them as a bad person. Tolerate everyone here, even if you despise them, and don't engage in arguments.")
.addField("Do not humiliate other people.","Mentioning previous drama or other situations any person was involved in is included.")
.addField("No excuses for punishment.","The rule nullification system exists for a valid reason. Staff don't care until someone complains. Don't use this system as a way to attempt to circumvent a punishment.")
.addField("Absolutely no NSFW content.","Shocking or graphic content, animal cruelty, and gore are not allowed whatsoever outside of the designated NSFW channels. Breaking this rule will result in a permanent ban on sight.");
const voicerules = new Discord.RichEmbed()
.setTitle("Voice Channel Rules")
.setColor(0x2f3136)
.addField("Most text rules apply in the voice chat.","Don't go crazy because of the channels being different.")
.addField("No loud audio.","Playing loud and/or annoying audio through your microphone or music bots is not allowed.")
.addField("Be responsible.","Everyone in the server holds the right to report users in the voice channels to have them muted as needed.")
.addField("Use common sense.","You can't escape this rule. Please don't ignore it.")
.addField("Limit the usage of voice changers.","Don't fake what you sound like. We prevent discrimination, you're fine.");
.addField("Limit the usage of voice changers.","Don't fake what you sound like. We prevent discrimination, you're fine.")
.addField("Don't blast music to others.","While we can limit which music bots can enter voice channels, we can't automatically stop other members from joining any of these channels with music blasting into their microphone.");
const punishmentsystem = new Discord.RichEmbed()
.setTitle("Punishment System")
.setColor(0x2f3136)
@ -102,7 +100,7 @@ exports.run = async (client, message, args) => {
await output.edit(`Landing has finished building in ${chnl}. This message will be removed in 5 seconds.`).then(output => {
output.delete(5000)
})
.catch(() => console.error("Error while deleting message."));
.catch(() => { });
}
sendLandingEmbeds();
};

View File

@ -0,0 +1,98 @@
const Discord = require("discord.js");
exports.run = async (client, message, args) => {
message.delete();
const output = await message.channel.send("Generating the Guidelines. Reading arguments...");
guild = message.guild;
let chnl = guild.channels.find(c => c.name === 'community-guidelines') || guild.channels.find(c => c.name === 'guidelines');
if(args[0]) {
chnl = args[0].substring("<#".length);
chnl = chnl.substring(chnl.length-1,0);
chnl = guild.channels.find(c => c.id === chnl);
output.edit(`Guidelines channel set to <#${chnl}>.`);
} else {
output.edit(`Arguments provided are invalid or channel was not found; set landing channel to ${chnl}.`);
}
async function clearGuidelinesChannel() {
let fetched;
fetched = await chnl.fetchMessages();
await output.edit(`Clearing messages in ${chnl}...`);
if(fetched) {
chnl.bulkDelete(fetched);
await output.edit(`Messages cleared in ${chnl}.`);
} else {
await output.edit(`No messages found in ${chnl}.`);
}
}
clearGuidelinesChannel();
const intro = new Discord.RichEmbed()
.setTitle("Discord Community Guidelines")
.setColor(0x2f3136)
.setDescription(`We created Discord to help people come together around games. It's been amazing to watch it grow into what it is today - a place where millions of diverse communities exist and people connect with old friends and new. We can't wait to see what's next.\n\nOur community guidelines are meant to explain what is and isnt allowed on Discord, and ensure that everyone has a good experience. If you come across a message that appears to break these rules, please report it to us. We may take a number of steps, including issuing a warning, removing the content, or removing the accounts and/or servers responsible.\n\nThe overwhelming majority of people use Discord responsibly, so these guidelines may seem obvious. Still, we want to be clear about the expectations for our users. Every user of Discord should feel like their voice can be heard, but not at the expense of someone else.`)
const interact = new Discord.RichEmbed()
.setTitle("Here are some rules for interacting with others:")
.setColor(0x2f3136)
.addField("Do not organize, participate in, or encourage harassment of others.","Disagreements happen and are normal, but continuous, repetitive, or severe negative comments may cross the line into harassment and are not okay.")
.addField("Do not organize, promote, or coordinate servers around hate speech.","Its unacceptable to attack a person or a community based on attributes such as their race, ethnicity, national origin, sex, gender, sexual orientation, religious affiliation, or disabilities.")
.addField("Do not make threats of violence or threaten to harm others.","This includes indirect threats, as well as sharing or threatening to share someones private personal information (also known as doxxing).")
.addField("Do not evade user blocks or server bans.","Do not send unwanted, repeated friend requests or messages, especially after theyve made it clear they dont want to talk to you anymore. Do not try to hide your identity in an attempt to contact someone who has blocked you, or otherwise circumvent the tools we have which enable users to protect themselves.")
.addField("Do not send others viruses or malware.","[Also, do not] attempt to phish others, or hack or DDoS them.")
const content = new Discord.RichEmbed()
.setTitle("Here are some rules for content on Discord:")
.setColor(0x2f3136)
.addField("You may not sexualize minors in any way.","This includes sharing content or links which depict minors in a pornographic, sexually suggestive, or violent manner, and includes illustrated or digitally altered pornography that depicts minors (such as lolicon, shotacon, or cub). We report illegal content to the [National Center for Missing and Exploited Children](https://www.missingkids.org/gethelpnow/cybertipline).")
.addField("You may not share sexually explicit content of other people without their consent.","In addition, you cannot share or promote sharing of non-consensual intimate imagery (also known as revenge porn) in an attempt to shame or degrade someone.")
.addField("You may not share content that glorifies or promotes suicide or self-harm.","This includes any encouragement to others to cut themselves, or embrace eating disorders such as anorexia or bulimia.")
.addField("You may not share images of sadistic gore or animal cruelty.","_ _")
.addField("You may not use Discord for the organization, promotion, or support of violent extremism.","_ _")
.addField("You may not operate a server that sells or facilitates the sales of prohibited or potentially dangerous goods.","This includes firearms, ammunition, drugs, and controlled substances.")
.addField("You may not promote, distribute, or provide access to content involving the hacking, cracking, or distribution of pirated software or stolen accounts.","This includes sharing or selling cheats or hacks that may negatively affect others in multiplayer games.")
.addField("In general, you should not promote, encourage or engage in any illegal behavior.","This is very likely to get you kicked off Discord, and may get you reported to law enforcement.");
const respect = new Discord.RichEmbed()
.setTitle("Finally, we ask that you respect Discord itself:")
.setColor(0x2f3136)
.addField("You may not sell your account or your server.","_ _")
.addField("You may not use self-bots or user-bots to access Discord.","_ _")
.addField("You may not share content that violates anyone's intellectual property or other rights.","_ _")
.addField("You may not spam Discord, especially our Customer Support and Trust & Safety teams.","Making false and malicious reports, sending multiple reports about the same issue, or asking a group of users to all report the same content may lead to action being taken on your account.");
const end = new Discord.RichEmbed()
.setTitle("Reporting users who break these Guidelines")
.setColor(0x2f3136)
.setDescription("If you see any activity that violates these guidelines, you can report it to us by filling out [this form](https://dis.gd/request).")
async function sendGuidelineEmbeds() {
await output.edit("Sending intro... *(Embed 1/5)*");
await chnl.send({embed: intro});
await output.edit("Sending interaction rules... *(Embed 2/5)*");
await chnl.send({embed: interact});
await output.edit("Sending content rules... *(Embed 3/5)*");
await chnl.send({embed: content});
await output.edit("Sending Discord's respect rules... *(Embed 4/5)*");
await chnl.send({embed: respect});
await output.edit("Sending ending... *(Embed 5/5)*");
await chnl.send({embed: end});
await output.edit(`Guidelines have been sent in ${chnl}. This message will be removed in 5 seconds.`).then(output => {
output.delete(5000)
})
.catch(() => { });
}
sendGuidelineEmbeds();
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: "Bot Owner"
};
exports.help = {
name: "guidelines",
category: "Channel Building",
description: "Builds the guidelines channel by purging the whole channel and sending embeds. Builds in first channel named **community-guidelines** _or_ **guidelines** if no arguments are provided.",
usage: "guidelines channel"
};

View File

@ -0,0 +1,85 @@
const Discord = require("discord.js");
exports.run = async (client, message, args) => {
message.delete();
const output = await message.channel.send("Generating the requests for adminship channel. Reading arguments...");
guild = message.guild;
let chnl = guild.channels.find(c => c.name === 'rfa-info');
if(args[0]) {
chnl = args[0].substring("<#".length);
chnl = chnl.substring(chnl.length-1,0);
chnl = guild.channels.find(c => c.id === chnl);
output.edit(`RfA info channel set to <#${chnl}>.`);
} else {
output.edit(`Arguments provided are invalid or channel was not found; set RfA channel to ${chnl}.`);
}
async function clearRfA() {
let fetched;
fetched = await chnl.fetchMessages();
await output.edit(`Clearing messages in ${chnl}.`);
if(fetched) {
chnl.bulkDelete(fetched);
await output.edit(`Messages cleared in ${chnl}.`);
} else {
await output.edit(`No messages found in ${chnl}.`);
}
}
clearRfA();
const intro = new Discord.RichEmbed()
.setTitle("Introduction")
.setColor(0x2f3136)
.setDescription(`Whether you're nominating yourself or somebody else, or simply reading what people say here, we welcome you warmly to the Requests for Adminship category. This category allows eligible users to nominate themselves for a staff position, [similar to how Wikipedia handles their admins](https://en.wikipedia.org/wiki/Wikipedia:Requests_for_adminship).`)
.addField("General standards", "On a normal basis, users who are of at least level 25 or above -- also known as being \"confirmed\", are at least 15 years of age and haven't had any infractions in the past month. The user being nominated must meet _all_ of these requirements, regardless of whether the nomination is from themselves or another user. If you are under level 25 _OR_ are of 13 or 14 years of age, it will be significantly more challenging for you to be accepted into the staff team.")
.addField("_ _","Without many positive contributions to the community, however, it is very unlikely that one may pass. People will look for a variety of factors in a candidate, and the discussion can be intense.");
const process = new Discord.RichEmbed()
.setTitle("Request for Staff Procedure")
.setColor(0x2f3136)
.addField("Publish.","A user can request to receive admin by simply submitting a form using the form at the bottom. Users can then notify an Elite that they've submitted their request.")
.addField("Discuss.","An ELITE will review the basic information, and then will make a channel specifically for the request, followed by a mention to the subject of the channel. All opinions and additional questions are asked in this channel, alongside discussion of what the user can and can't do.\nA pinned message will be placed to allow for voting on the user with reactions; a thumbs up (`:thumbsup:`) for yes, a thumbs down (`:thumbsdown:`) for no, or a question mark (`:grey_question:`) for neutral.")
.addField("Ask.","The user may have answered the base 3 questions, but they must also answer all questions by **quoting the original message, and keep the mention intact when the candidate responds to the query.** Elites will be requested to pin all answered questions to the channel for easy access. These questions can include \"what would you do in situation X?\" or \"what can you not do with discord that may hinder you?\". Keep the questions mature and civil; immaturity will result in mutes, kicks or bans.")
.addField("Decide.","Once you think you've learned enough, head to the pinned messages and jump to the decision message. React to **__ONE__** reaction on the message; multiple will make the reviewer assume you are unsure. You can change your votes at any time; be sure to keep it at one reaction only.")
.addField("Closure.","After around one week of the RfA being open, the Elites will close the request and tally the votes:\n - Users with at least 75% support will always pass\n - Users with support varying from 65% to 75% will be left with the Elites deciding\n - Users with **at most** 65% will most likely be declined\n\nIf your nomination fails, then please wait for a reasonable period of time before renominating yourself or accepting another nomination. Some candidates have tried again and succeeded within three months, but many people prefer to wait considerably longer before reapplying.");
const nomination = new Discord.RichEmbed()
.setTitle("Nomating users or yourself")
.setColor(0x2f3136)
.addField("Before you start,","If you're nominating someone else, make sure they're okay with it __before__ you make your nomination. If you're going with self-nomination, be sure you know exactly what you're doing.")
.addField("Nomation Form","Nominate yourself by clicking the form below, or if you are nominating someone else, use this form: https://forms.gle/zArWXC2a6oZ9oHS36");
const questions = new Discord.RichEmbed()
.setTitle("Candidate Questions")
.setColor(0x2f3136)
.setDescription("[Open the questions form by clicking this text.](https://forms.gle/ue28VSULnPpcGWJu8)")
async function sendRfAEmbeds() {
await output.edit("Sending intro... *(Embed 1/4)*");
await chnl.send({embed: intro});
await output.edit("Sending process for staff... *(Embed 2/4)*");
await chnl.send({embed: process});
await output.edit("Sending nomination guidelines... *(Embed 3/4)*");
await chnl.send({embed: nomination});
await output.edit("Sending questions embed... *(Embed 4/4)*");
await chnl.send({embed: questions});
await output.edit(`RfA guidelines have finished building in ${chnl}. This message will be removed in 5 seconds.`).then(output => {
output.delete(5000)
})
.catch(() => { });
}
sendRfAEmbeds();
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: "Bot Owner"
};
exports.help = {
name: "rfa",
category: "Channel Building",
description: "Builds the Requests for Adminship channel by purging the whole channel and sending embeds. Builds in first channel named **rfa-info** if no arguments are provided.",
usage: "rfa channel"
};

View File

@ -1,54 +1,132 @@
const { RichEmbed } = require('discord.js');
const stripIndents = require('common-tags').stripIndents;
exports.run = (client, message, args, level) => {
exports.run = async (client, message, args, level) => {
message.delete();
if (!args[0]) {
const myCommands = message.guild ? client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level) : client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true);
const commandNames = myCommands.keyArray();
const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
let currentCategory = "";
let output = `= Command List =\n\n[Use ${message.settings.prefix}help <commandname> for details]\n`;
const sorted = myCommands.array().sort((p, c) => p.help.category > c.help.category ? 1 : p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1 );
sorted.forEach( c => {
const cat = c.help.category.toProperCase();
if (currentCategory !== cat) {
output += `\u200b\n== ${cat} ==\n`;
currentCategory = cat;
let commands = client.commands;
let title = "Categories";
if(args[0]) {
if(args[0] === "category" || args[0] === "type") {
if(!args[1]) {
return (await message.reply("you must specify a valid category!")).delete(5000).catch(() => { });
}
output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: ${c.help.description}\n`;
});
message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }});
} else {
let command = args[0];
if (client.commands.has(command)) {
command = client.commands.get(command);
if (level < client.levelCache[command.conf.permLevel]) return;
message.channel.send({embed: client.embed(`Command information: "${command.help.name}"`, command.help.description, [
commands = client.commands.filter(cmd => cmd.help.category === args[1]);
title = `== ${args[1]} commands ==`;
} else if(args[0] === "all" || args[0] === "full" || args[0] === "every") {
commands = message.guild ? client.commands : client.commands.filter(cmd.conf.guildOnly !== true);
title = "== All Commands =="
} else if(args[0] === "mine" || args[0] === "usable") {
commands = message.guild ? client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level) : client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true);
title = `== ${message.author.username}'s Usable Commands ==`
} else {
let command = args[0];
if (client.commands.has(command)) {
command = client.commands.get(command);
if (level < client.levelCache[command.conf.permLevel]) return;
message.channel.send({embed: client.embed(`Command information: "${command.help.name}"`, command.help.description, [
{
name: 'Category',
value: command.help.category !== "" ? command.help.category : "none",
inline: true
},
{
name: 'Usage',
value: command.help.usage,
inline: true
},
{
name: 'Aliases',
value: command.conf.aliases.join(", ") !== "" ? command.conf.aliases.join(", ") : "none",
inline: true
}
],
{
name: 'Category',
value: command.help.category !== "" ? command.help.category : "none",
inline: true
},
{
name: 'Usage',
value: command.help.usage,
inline: true
},
{
name: 'Aliases',
value: command.conf.aliases.join(", ") !== "" ? command.conf.aliases.join(", ") : "none",
inline: true
}
],
{
author: message.author.tag,
authorIcon: message.author.avatarURL
})
});
author: message.author.tag,
authorIcon: message.author.avatarURL
})
});
}
}
}
if(commands.length > 0) {
let fields = commands
.sort((a,b) => a.help.name.localeCompare(b.help.name))
.map(c => getHelp(client, c, commands.length === 1));
let maxLength = 1900;
let messages = [];
while(fields.length > 0) {
let len = 0;
let i = 0;
while(len < maxLength) {
if(i >= fields.length) break;
let field = fields[i];
len += field.name.length + field.value.length;
if(len >= maxLength) break;
i++;
}
messages.push({ fields: fields.splice(0,i) });
}
message.delete().catch(() => { });
messages.map(m => m.fields).forEach(async fields => {
(await message.channel.send({
embed: client.embed(title,'_This message will self-destruct in 90 seconds._ :boom:',fields)
})).delete(90000).catch(() => { });
});
} else {
// let categories = client.categories().sort();
let categories;
(await message.channel.send({
embed: client.embed(title,stripIndents
`**Available categories:**
${categories.map(c => `- __${c}__`).join('\n')}
\`\`\`asciidoc
== Usage ==
${message.settings.prefix}help category <name> :: Provides a list of comamnds in a specific category.
${message.settings.prefix}help all :: Shows a list of every command available for this bot.
${message.settings.prefix}help mine :: Presents a list of all commands that your permission level has access to.
${message.settings.prefix}help <command> :: Sends extended command help and extra options.
\`\`\``)
})).delete(15000);
}
};
const getHelp = (bot, command, single) => {
let description = stripIndents`
**Usage:** \`${message.settings.prefix}${command.help.usage || command.help.name}\`
**Description:** ${command.help.description || '<no description>'}
**Category:** __${command.help.category}__`;
if (command.help.credits)
description += `\n**Credits:** *${command.help.credits}*`;
if (single && command.help.examples)
description += `\n**Examples:**\n${command.help.examples.map(example => `\`${message.settings.prefix}${example}\``).join('\n')}`;
if (single && command.help.options instanceof Array) {
let options = command.help.options.map(option => {
return stripIndents`
**${option.name}**
*Usage:* \`${option.usage || option.name}\`
*Description:* ${option.description}
`;
});
description += `\n**Options:**\n\n${options.join('\n\n')}`;
}
return {
name: single ? '\u200b' : command.help.name,
value: description
};
};
exports.conf = {
@ -64,3 +142,22 @@ exports.help = {
description: "Displays all the available commands for your permission level.",
usage: "help [command]"
};
/*
const myCommands = message.guild ? client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.help.category === args[1]) : client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true && cmd.help.category === args[1]);
const commandNames = myCommands.keyArray();
const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
let currentCategory = "";
let output;
const sorted = myCommands.array().sort((p, c) => p.help.category > c.help.category ? 1 : p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1 );
sorted.forEach( c => {
const cat = c.help.category.toProperCase();
if (currentCategory !== cat) {
output += `\u200b\n== ${cat} ==\n`;
currentCategory = cat;
}
output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: ${c.help.description}\n`;
});
*/

View File

@ -38,7 +38,7 @@ const init = async () => {
await crawl("commands",cmdFiles);
client.logger.log(`Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach(f => {
if (!f.endsWith(".js") || f.startsWith("commands\\_")) return;
if (!f.endsWith(".js") || f.startsWith("commands/_")) return;
const response = client.loadCommand(f);
if (response) console.log(response);
});

View File

@ -18,7 +18,7 @@ module.exports = (client) => {
}
return permlvl;
};
const defaultSettings = {
"prefix": "b&",
"modLogChannel": "mod-log",
@ -29,14 +29,14 @@ module.exports = (client) => {
"welcomeMessage": "Say hello to {{user}}, everyone! We all need a warm welcome sometimes :D",
"welcomeEnabled": "false"
};
client.getSettings = (guild) => {
client.settings.ensure("default", defaultSettings);
if(!guild) return client.settings.get("default");
const guildConf = client.settings.get(guild.id) || {};
return ({...client.settings.get("default"), ...guildConf});
};
client.awaitReply = async (msg, question, limit = 60000) => {
const filter = m => m.author.id === msg.author.id;
await msg.channel.send(question);
@ -47,22 +47,7 @@ module.exports = (client) => {
return false;
}
};
client.caseNumber = async (client, modlog) {
const messages = await modlog.fetchMessages({limit:5});
const log = messages.filter(m => m.author.id === client.user.id &&
m.embeds[0] &&
m.embeds[0].type === 'rich' &&
m.embeds[0].footer &&
m.embeds[0].footer.text.startsWith('Case')
).first();
if (!log) return 1;
const thisCase = /Case\s(\d+)/.exec(log.embeds[0].footer.text);
return thisCase ? parseInt(thisCase[1]) + 1 : 1;
};
client.clean = async (client, text) => {
if (text && text.constructor.name == "Promise")
text = await text;
@ -94,41 +79,41 @@ module.exports = (client) => {
}
};
client.unloadCommand = async (commandName) => {
let command;
if (client.commands.has(commandName)) {
command = client.commands.get(commandName);
} else if (client.aliases.has(commandName)) {
command = client.commands.get(client.aliases.get(commandName));
}
if (!command) return `The command \`${commandName}\` doesn\'t seem to exist, nor is it an alias. Try again!`;
client.unloadCommand = async (commandName) => {
let command;
if (client.commands.has(commandName)) {
command = client.commands.get(commandName);
} else if (client.aliases.has(commandName)) {
command = client.commands.get(client.aliases.get(commandName));
}
if (!command) return `The command \`${commandName}\` doesn\'t seem to exist, nor is it an alias. Try again!`;
if (command.shutdown) {
await command.shutdown(client);
}
const mod = require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}`)];
delete require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}.js`)];
for (let i = 0; i < mod.parent.children.length; i++) {
if (mod.parent.children[i] === mod) {
mod.parent.children.splice(i, 1);
break;
}
}
return false;
if (command.shutdown) {
await command.shutdown(client);
}
const mod = require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}`)];
delete require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}.js`)];
for (let i = 0; i < mod.parent.children.length; i++) {
if (mod.parent.children[i] === mod) {
mod.parent.children.splice(i, 1);
break;
}
}
return false;
};
Object.defineProperty(String.prototype, "toProperCase", {
value: function() {
return this.replace(/([^\W_]+[^\s-]*) */g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
}
});
Object.defineProperty(Array.prototype, "random", {
value: function() {
return this[Math.floor(Math.random() * this.length)];
}
});
client.wait = require("util").promisify(setTimeout);
client.randomSelection = choices => choices[Math.floor(Math.random() * choices.length)];
@ -346,9 +331,24 @@ module.exports = (client) => {
client.quoteRegex = input => `${input}`.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&');
client.fetchURL = (url, options = {}) => {
options.headers = options.headers ? { ...options.headers, "User-Agent": client.user } : { "User-Agent": client.user };
return fetch(url, options, options.type || "json").catch(error => {
client.Logger.error(error);
});
}
};
options.headers = options.headers ? { ...options.headers, "User-Agent": client.user } : { "User-Agent": client.user };
return fetch(url, options, options.type || "json").catch(error => {
client.Logger.error(error);
});
}
client.caseNumber = async (client, modlog) => {
const messages = await modlog.fetchMessages({limit:5});
const log = messages.filter(m => m.author.id === client.user.id &&
m.embeds[0] &&
m.embeds[0].type === 'rich' &&
m.embeds[0].footer &&
m.embeds[0].footer.text.startsWith('Case')
).first();
if (!log) return 1;
const thisCase = /Case\s(\d+)/.exec(log.embeds[0].footer.text);
return thisCase ? parseInt(thisCase[1]) + 1 : 1;
};
};