-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7348ab7
commit 4e37a56
Showing
6 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { Command } = require("discord.js-commando"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const jsonPath = path.join(__dirname, "../../data/servers.json"); | ||
module.exports = class RoleAddCommand extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: "roleadd", | ||
group: "roleme", | ||
memberName: "roleadd", | ||
description: "Adds a role to the roleme list", | ||
examples: ["roleadd updates"], | ||
guildOnly: true, | ||
args: [ | ||
{ | ||
key: "role", | ||
prompt: "Which role should be added?", | ||
type: "role" | ||
} | ||
] | ||
}); | ||
} | ||
async run(msg, { role }) { | ||
const data = JSON.parse(fs.readFileSync(jsonPath), "utf8"); | ||
if ( | ||
!msg.member.permissions.has("ADMINISTRATOR") && | ||
msg.author.id !== msg.guild.ownerID | ||
) | ||
return msg.reply( | ||
":no_entry_sign: [**Invalid Permissions**]: You don't have the **Administrator** permission!" | ||
); | ||
if (!data[msg.guild.id].roles) { | ||
data[msg.guild.id].roles.push({ role: role }); | ||
fs.writeFileSync(jsonPath, JSON.stringify(data, null, 2)); | ||
} else { | ||
let duplicate = false; | ||
let toCheck = data[msg.guild.id].roles; | ||
for (let i = 0; i < toCheck.length; i++) { | ||
if (toCheck.role[i] == role) { | ||
duplicate = true; | ||
break; | ||
} | ||
if (duplicate == true) { | ||
msg.channel.send("Role is already added!"); | ||
} else { | ||
data[msg.guild.id].roles.push({ role: role }); | ||
fs.writeFileSync(jsonPath, JSON.stringify(data, null, 2)); | ||
} | ||
} | ||
} | ||
} | ||
}; |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters