From 7826f959768646a4316295ef6d1a409c00816d77 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Thu, 22 Apr 2021 18:01:40 +0100 Subject: [PATCH] Change rules.txt to rules.json --- commands/rules.js | 43 ++++++++++------------ config.template.json | 8 ++--- data/rules/rules.json | 84 +++++++++++++++++++++++++++++++++++++++++++ data/rules/rules.txt | 41 --------------------- package-lock.json | 4 +-- 5 files changed, 109 insertions(+), 71 deletions(-) create mode 100644 data/rules/rules.json delete mode 100644 data/rules/rules.txt diff --git a/commands/rules.js b/commands/rules.js index 14afa82..266e504 100644 --- a/commands/rules.js +++ b/commands/rules.js @@ -25,35 +25,30 @@ class rules extends command { if (context.message.member.roles.cache.find(role => role.name == context.client.config.rules.adminrole)) { // If the rulesfile exists if (existsSync(context.client.config.rules.rulesfile)) { - // Get the contents of the rules file, and split it by "> " - // Each embed in the rules is set by the "> " syntax - let rulesText = readFileSync(context.client.config.rules.rulesfile).toString(); - rulesText = rulesText.split("> "); + const rulesJson = readFileSync(context.client.config.rules.rulesfile); + const rules = JSON.parse(rulesJson); - // Loop through each embed to be sent - for (let i = 0; i < rulesText.length; i++) { - // If the first line after "> " has a "#", create and embed with an image of the url specified after - if (rulesText[i].charAt(0) == '#') { - const embed = new MessageEmbed() - .setColor(embedColor) - .setImage(rulesText[i].substring(1)); + for (let i = 0; i < rules.length; i++) { + const rule = rules[i]; + const embed = new MessageEmbed(); - context.message.channel.send(embed); - } else { // If the file doesn't have a "#" at the start - // Split the embed into different lines, set the first line as the title, and the rest as the description - const rulesLines = rulesText[i].split("\n"); - const rulesTitle = rulesLines[0]; - const rulesDescription = rulesLines.slice(1).join("\n"); + embed.setColor(embedColor); - // Create the embed with the specified information above - const embed = new MessageEmbed() - .setTitle(rulesTitle) - .setColor(embedColor) - .setDescription(rulesDescription); + if (rule.image) embed.setImage(rule.image); + if (rule.title) embed.setTitle(rule.title); + if (rule.footer) embed.setFooter(rule.footer); + if (rule.description) { + let description = ""; - // Send the embed - context.message.channel.send(embed); + for (let j = 0; j < rule.description.length; j++) { + const line = rule.description[j]; + description += `${line}\n`; + } + + embed.setDescription(description); } + + context.message.channel.send(embed); } } else { // If the rules file doesn't exist const errorEmbed = new MessageEmbed() diff --git a/config.template.json b/config.template.json index 1be9777..2739903 100644 --- a/config.template.json +++ b/config.template.json @@ -1,6 +1,6 @@ { "token": "", - "prefix": "d!", + "prefix": "v!", "commands": [ "commands" ], @@ -9,10 +9,10 @@ ], "about": { "description": "Discord Bot for Vylpes' Den", - "version": "2.1", + "version": "2.2", "core-ver": "1.0.4", "author": "Vylpes", - "date": "17-Feb-21" + "date": "22/04/2021" }, "ban": { "modrole": "Moderator", @@ -40,7 +40,7 @@ }, "rules": { "adminrole": "Admin", - "rulesfile": "data/rules/rules.txt" + "rulesfile": "data/rules/rules.json" }, "unmute": { "modrole": "Moderator", diff --git a/data/rules/rules.json b/data/rules/rules.json new file mode 100644 index 0000000..e65a2ce --- /dev/null +++ b/data/rules/rules.json @@ -0,0 +1,84 @@ +[ + { + "image": "https://i.imgur.com/bjH1gza.png" + }, + { + "title": "Vylpes' Den", + "description": [ + "Welcome to Vylpes' Den! Make sure to say hi!", + "Invite link: https://discord.gg/UyAhAVp" + ] + }, + { + "title": "Discord TOS", + "description": [ + "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 know them!", + "https://discord.com/terms" + ] + }, + { + "title": "Rules", + "description": [ + "**English Only**", + "In order for everyone to understand each other we would like to ask everyone to speak in English only.", + "", + "**No NSFW or Obscene Content**", + "This includes text, images, or links featuring nudity, sex, hard violence, or other graphically disturbing content.", + "", + "**Treat Everyone with Respect**", + "Absolutely no harassment, witch hunting, sexism, racism, or hate speech will be tolerated.", + "", + "**No spam or self promotion**", + "Outside of #self-promo. This includes DMing fellow members.", + "", + "**Keep Politics to #general**", + "And make sure it doesn't become too heated. Debate don't argue.", + "", + "**Drama From Other Servers**", + "Please don't bring up drama from other servers, keep that to DMs", + "", + "**Bot Abuse**", + "Don't abuse the bots or you will be blocked from using them" + ] + }, + { + "title": "Moderators Discretion", + "description": [ + "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)." + ] + }, + { + "title": "Supporters", + "description": [ + "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!" + ] + }, + { + "title": "Self-Assignable Roles", + "description": [ + "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.", + "VotePings: Get pinged when I start a new poll", + "ProjectUpdates: Get pinged when I update my projects as well as new for them" + ] + }, + { + "title": "VylBot", + "description": [ + "This server uses a bot made by me, VylBot, to help moderate the server.", + "For more information on it, see the GitHub repositories:", + "https://github.com/Vylpes/vylbot-core", + "https://github.com/Vylpes/vylbot-app" + ] + }, + { + "title": "Links", + "description": [ + "YouTube: https://www.youtube.com/channel/UCwPlzKwCmP5Q9bCX3fHk2BA", + "Patreon: https://www.patreon.com/vylpes", + "Twitch: https://www.twitch.tv/vylpes_", + "Twitter: https://twitter.com/vylpes" + ], + "footer": "Last updated 22/04/2021" + } +] \ No newline at end of file diff --git a/data/rules/rules.txt b/data/rules/rules.txt deleted file mode 100644 index 071557a..0000000 --- a/data/rules/rules.txt +++ /dev/null @@ -1,41 +0,0 @@ -> #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 or Obscene Content** -This includes text, images, or links featuring nudity, sex, hard violence, or other graphically disturbing content. - -- **Treat Everyone with Respect** -Absolutely no harassment, witch hunting, sexism, racism, or hate speech will be tolerated. - -- **No spam or self promotion** -Outside of #self-promo. This includes DMing fellow members. - -- **Keep Politics to #general** -And make sure it doesn't become too heated. Debate don't argue. - -- **Drama From Other Servers** -Please don't bring up drama from other servers, keep that to DMs - -- **Bot Abuse** -Don't abuse the bots or you will be blocked from using them - -> 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 - diff --git a/package-lock.json b/package-lock.json index a9c8367..28fa8b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "vylbot-app", - "version": "1.0.0", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.0.0", + "version": "2.1.0", "license": "ISC", "dependencies": { "emoji-regex": "^9.2.0", -- 2.43.4