From d2493f9131ab9ad8b10493d6d13021b5b71ecf0f Mon Sep 17 00:00:00 2001 From: Vylpes Date: Wed, 4 Nov 2020 19:58:54 +0000 Subject: [PATCH] Add role and rules command --- commands/role.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++ commands/rules.js | 60 ++++++++++++++++++++++++++++++++ rules.txt | 48 ++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 commands/role.js create mode 100644 commands/rules.js create mode 100644 rules.txt diff --git a/commands/role.js b/commands/role.js new file mode 100644 index 0000000..4721285 --- /dev/null +++ b/commands/role.js @@ -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 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; \ No newline at end of file diff --git a/commands/rules.js b/commands/rules.js new file mode 100644 index 0000000..f9b7f80 --- /dev/null +++ b/commands/rules.js @@ -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; \ No newline at end of file diff --git a/rules.txt b/rules.txt new file mode 100644 index 0000000..906b62f --- /dev/null +++ b/rules.txt @@ -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 . 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 \ No newline at end of file