Change rules.txt to rules.json

This commit is contained in:
Vylpes 2021-04-22 18:01:40 +01:00
parent 25c4f8c8fd
commit 7826f95976
5 changed files with 109 additions and 71 deletions

View file

@ -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()

View file

@ -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",

84
data/rules/rules.json Normal file
View file

@ -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 <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"
}
]

View file

@ -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 <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

4
package-lock.json generated
View file

@ -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",