mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-09-01 01:35:17 +00:00
* Remade commands: price, rank, userinfo,hash,lbrylink, releasenotes, stats, supportbot. * Added modlogs and settings for modlogs. * Commands can now be locked to channels with the locktochannel module. * customCommand/triggers can be saved in mongodb and edited on the fly, the bot will always use the latest messages. This commit does not contain: * A working claimbot, the new implantation with chainquery is on the way, this will be a seperate issue. * A working webinterface, therefor, some items does not work, this will be a seperate issue. This means that this code should remain in the wunderbot-v2 branch until a working webinterface where we can control the custom triggers/commands and other settings for the bot.
75 lines
3.8 KiB
JavaScript
75 lines
3.8 KiB
JavaScript
import { Command } from "discord.js-commando";
|
|
import { RichEmbed } from "discord.js";
|
|
import { oneLine } from "common-tags";
|
|
|
|
module.exports = class PubRanksCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: "pubranks",
|
|
aliases: ["editranks", "editroles", "pubrank", "editroleme"],
|
|
group: "moderation",
|
|
memberName: "pubranks",
|
|
description: "Manages a server's public roles.",
|
|
details: oneLine`
|
|
Do you want to have an opt-in only NSFW channel? A role that you can ping to avoid pinging everyone?
|
|
This command allows for management of a server's public roles.
|
|
Note: Adding and removing public roles must be done by someone with the MANAGE_ROLES permission.
|
|
`,
|
|
examples: ["pubranks add ping"],
|
|
args: [
|
|
{
|
|
key: "action",
|
|
label: "action",
|
|
prompt: "What action would you like to preform? (`add`, `remove`, or `list`)",
|
|
type: "string",
|
|
infinite: false
|
|
},
|
|
{
|
|
key: "rank",
|
|
label: "rank",
|
|
prompt: "",
|
|
type: "string",
|
|
default: "",
|
|
infinite: false
|
|
}
|
|
],
|
|
guildOnly: true,
|
|
guarded: true
|
|
});
|
|
}
|
|
|
|
async run(msg, args) {
|
|
if (args.action.toLowerCase() === "add") {
|
|
if (!msg.guild.member(msg.author).hasPermission("MANAGE_ROLES", false, true, true)) return msg.reply(`You do not have permission to perform this action! Did you mean \`${msg.guild.commandPrefix}rank give\`?`);
|
|
const guildRanks = await msg.guild.settings.get("ranks", []);
|
|
const rankToAdd = msg.guild.roles.find("name", args.rank);
|
|
if (rankToAdd === null) return msg.reply("That is not a role! Was your capatalization and spelling correct?");
|
|
guildRanks.push(args.rank);
|
|
await msg.guild.settings.set("ranks", guildRanks);
|
|
msg.reply("Role added.");
|
|
} else if (args.action.toLowerCase() === "remove" || args.action.toLowerCase() === "delete") {
|
|
if (!msg.guild.member(msg.author).hasPermission("MANAGE_ROLES", false, true, true)) return msg.reply(`You do not have permission to perform this action! Did you mean\`${msg.guild.commandPrefix}rank take\`?`);
|
|
const guildRanks = await msg.guild.settings.get("ranks", []);
|
|
const rankIndex = guildRanks.indexOf(args.rank);
|
|
const rankToRemove = msg.guild.roles.find("name", args.rank);
|
|
if (rankToRemove === null) return msg.reply("That is not a role! Was your capatalization and spelling correct?");
|
|
guildRanks.splice(rankIndex, 1);
|
|
msg.reply("Role removed.");
|
|
-await msg.guild.settings.set("ranks", guildRanks);
|
|
} else if (args.action.toLowerCase() === "list") {
|
|
const guildRanks = await msg.guild.settings.get("ranks", null);
|
|
if (!guildRanks) return msg.reply(`There are no public roles! Maybe try adding some? Do \`${msg.guild.commandPrefix}pubranks add role\` to add a role.`);
|
|
let rankList = "";
|
|
guildRanks.forEach(rank => {
|
|
rankList += `${rank}\n`;
|
|
});
|
|
const rankEmbed = new RichEmbed();
|
|
rankEmbed.setAuthor("Wunderbot | Rank Controller").setColor(7976557);
|
|
if (rankList) rankEmbed.addField("Ranks available:", rankList, true);
|
|
msg.embed(rankEmbed);
|
|
} else {
|
|
return msg.reply(`Invalid command usage. Please use \`add\`, \`remove\`, or \`list\`.
|
|
**NOTE:** If you are trying to give yourself a role, do \`${msg.guild.commandPrefix}rank give role\`.`);
|
|
}
|
|
}
|
|
};
|