Add role and rules command

This commit is contained in:
Vylpes 2020-11-04 19:58:54 +00:00
parent 58cf283777
commit d2493f9131
3 changed files with 195 additions and 0 deletions

87
commands/role.js Normal file
View file

@ -0,0 +1,87 @@
const { command } = require('vylbot-core');
const { MessageEmbed } = require('discord.js');
const embedColor = "0x3050ba";
class role extends command {
constructor() {
super("role");
super.description = "Toggles a role for the user to gain/remove";
super.category = "General";
super.usage = "[name]";
super.requiredConfigs = "assignable";
}
role(context) {
let roles = context.client.config.role.assignable;
let requestedRole = "";
if (context.arguments.length > 0) {
for (let i = 0; i < roles.length; i++) {
if (roles[i].toLowerCase() == context.arguments[0].toLowerCase()) {
requestedRole = roles[i];
}
}
if (requestedRole != "") {
let role = context.message.guild.roles.cache.find(r => r.name == requestedRole);
if (context.message.member.roles.cache.find(r => r.name == requestedRole)) {
context.message.member.roles.remove(role).then(() => {
let embed = new MessageEmbed()
.setColor(embedColor)
.setDescription(`Removed role: ${requestedRole}`);
context.message.channel.send(embed);
}).catch(err => {
console.error(err);
let errorEmbed = new MessageEmbed()
.setColor(embedColor)
.setDescription("An error occured. Please check logs");
context.message.channel.send(errorEmbed);
});
} else {
context.message.member.roles.add(role).then(() => {
let embed = new MessageEmbed()
.setColor(embedColor)
.setDescription(`Gave role: ${requestedRole}`);
context.message.channel.send(embed);
}).catch(err => {
console.error(err);
let errorEmbed = new MessageEmbed()
.setColor(embedColor)
.setDescription("An error occured. Please check logs");
context.message.channel.send(errorEmbed);
});
}
} else {
let embed = new MessageEmbed()
.setColor(embedColor)
.setDescription("This role does not exist, see assignable roles with the role command (no arguments)");
context.message.channel.send(embed);
}
} else {
let rolesString = `Do ${context.client.config.prefix}role <role> to get the role!\n`;
for (let i = 0; i < roles.length; i++) {
rolesString += `${roles[i]}\n`;
}
let embed = new MessageEmbed()
.setTitle("Roles")
.setColor(embedColor)
.setDescription(rolesString);
context.message.channel.send(embed);
}
}
}
module.exports = role;

60
commands/rules.js Normal file
View file

@ -0,0 +1,60 @@
const { command } = require('vylbot-core');
const { MessageEmbed } = require('discord.js');
const { existsSync, readFileSync } = require('fs');
const embedColor = "0x3050ba";
class rules extends command {
constructor() {
super("rules");
super.description = "Generates the rules embeds from the rules.txt file";
super.category = "Administration";
super.requiredConfigs = "adminrole";
super.requiredConfigs = "rulesfile";
}
rules(context) {
if (context.message.member.roles.cache.find(role => role.name == context.client.config.rules.adminrole)) {
if (existsSync(context.client.config.rules.rulesfile)) {
let rulesText = readFileSync(context.client.config.rules.rulesfile).toString();
rulesText = rulesText.split("> ");
for (let i = 0; i < rulesText.length; i++) {
if (rulesText[i].charAt(0) == '#') {
let embed = new MessageEmbed()
.setColor(embedColor)
.setImage(rulesText[i].substring(1));
context.message.channel.send(embed);
} else {
let rulesLines = rulesText[i].split("\n");
let rulesTitle = rulesLines[0];
let rulesDescription = rulesLines.slice(1).join("\n");
let embed = new MessageEmbed()
.setTitle(rulesTitle)
.setColor(embedColor)
.setDescription(rulesDescription);
context.message.channel.send(embed);
}
}
} else {
let errorEmbed = new MessageEmbed()
.setColor(embedColor)
.setDescription(`${context.client.config.rules.rulesfile} doesn't exist`);
context.message.channel.send(errorEmbed);
}
} else {
let errorEmbed = new MessageEmbed()
.setColor(embedColor)
.setDescription("You do not have permission to run this command");
context.message.channel.send(errorEmbed);
}
}
}
module.exports = rules;

48
rules.txt Normal file
View file

@ -0,0 +1,48 @@
> #https://i.imgur.com/bjH1gza.png
> Vylpes' Den
Welcome to Vylpes' Den! Make sure to say hi!
Invite link: https://discord.gg/UyAhAVp
> Discord TOS
All servers are required to follow the Discord Terms of Service. This includes minimum age requirements (13+). If the moderation team discover a breach of TOS we are required by discord to ban. Make sure you follow them! - https://discord.com/terms
> Rules
- **English Only**
In order for everyone to understand each other we would like to ask everyone to speak in English only.
- **No NSFW content**
Please keep all content SFW, including profile pictures, usernames, and nicknames.
- **No Excessive Swearing**
You may swear in moderation, but please don't overdo it.
- **Do Not Spam**
This includes posting repeatedly the same text in a short amount of time, copypastas, etc.
- **Caps Lock**
Having your entire message in capitals counts as spam. You may do it to show emotion, but please keep it to a minimum. Same applies to bold characters. Grammatical use of all caps is allowed.
- **Toxicity**
Do not be toxic towards others.
- **Backseat Modding**
Do not backseat mod. Its annoying for the moderators. If no mod is available you can help but if a mod is there, let them handle it or ping them if needed.
- **Politics**
Please keep politics to #general, and make sure it doesn't become too heated. Debate don't argue.
- **Self Promotion**
Self promotion of your own content is allowed in #self-promo only. You, however, are allowed to post links to others' work in the appropriate channel.
- **No Drama**
Please don't bring up drama from other servers, keep that to DMs
> Moderators Discretion
Don't argue with a mod's decision. A moderator's choice is final. If you have an issue with a member of the mod team DM me (Vylpes#0001).
> Supporters
If you are a Twitch Subscriber or a Patreon Member and have linked your profiles to your discord account you will get exclusive access to the Vylpes Plus channels, including early access to videos!
> Self-Assignable Roles
If you want to assign yourself roles, go to #bot-stuff and type v!role <role>. The current roles you can get are:
Notify: Get pinged when a new stream or video releases.
> Links
YouTube: https://www.youtube.com/channel/UCwPlzKwCmP5Q9bCX3fHk2BA
Patreon: https://www.patreon.com/vylpes
Twitch: https://www.twitch.tv/vylpes_
Twitter: https://twitter.com/vylpes