2022-08-08 18:19:56 +05:00
|
|
|
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Autorole extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("autorole")
|
|
|
|
.setDescription(client.translate("administration/autorole:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-11-09 21:33:45 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
2022-08-08 18:19:56 +05:00
|
|
|
.addBooleanOption(option => option.setName("state")
|
|
|
|
.setDescription(client.translate("common:STATE"))
|
|
|
|
.setRequired(true))
|
|
|
|
.addRoleOption(option => option.setName("role")
|
|
|
|
.setDescription(client.translate("common:ROLE"))),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction, data) {
|
|
|
|
const state = interaction.options.getBoolean("state");
|
|
|
|
|
|
|
|
if (state) {
|
2022-08-09 23:48:33 +05:00
|
|
|
const role = interaction.options.getRole("role");
|
2022-08-08 18:19:56 +05:00
|
|
|
if (!role) return interaction.error("administration/autorole:MISSING_ROLE");
|
|
|
|
|
|
|
|
data.guildData.plugins.autorole = {
|
|
|
|
enabled: true,
|
2022-12-15 21:02:38 +05:00
|
|
|
role: role.id,
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.autorole");
|
|
|
|
await data.guildData.save();
|
|
|
|
|
|
|
|
interaction.success("administration/autorole:SUCCESS_ENABLED", {
|
2022-12-15 21:02:38 +05:00
|
|
|
role: role.toString(),
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
data.guildData.plugins.autorole = {
|
|
|
|
enabled: false,
|
2022-12-15 21:02:38 +05:00
|
|
|
role: null,
|
2022-08-08 18:19:56 +05:00
|
|
|
};
|
|
|
|
data.guildData.markModified("plugins.autorole");
|
|
|
|
await data.guildData.save();
|
|
|
|
|
2022-08-09 23:48:33 +05:00
|
|
|
interaction.success("administration/autorole:SUCCESS_DISABLED");
|
2022-08-08 18:19:56 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Autorole;
|