29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
const { SlashCommandBuilder } = require('discord.js');
|
|
const api = require('../api');
|
|
|
|
module.exports = {
|
|
name: 'view-autorole',
|
|
description: 'View the current autorole configuration for this server.',
|
|
enabled: true,
|
|
builder: new SlashCommandBuilder()
|
|
.setName('view-autorole')
|
|
.setDescription('View the current autorole configuration for this server.'),
|
|
async execute(interaction) {
|
|
const guildId = interaction.guildId;
|
|
const settings = (await api.getServerSettings(guildId)) || {};
|
|
const autorole = settings.autorole || { enabled: false, roleId: '' };
|
|
|
|
if (!autorole.enabled) {
|
|
await interaction.reply({ content: 'Autorole is currently disabled for this server.', flags: 64 });
|
|
return;
|
|
}
|
|
|
|
const role = interaction.guild.roles.cache.get(autorole.roleId);
|
|
if (role) {
|
|
await interaction.reply({ content: `Autorole is enabled. Selected role: ${role.toString()} (${role.name}).`, flags: 64 });
|
|
} else {
|
|
await interaction.reply({ content: `Autorole is enabled but the selected role (ID: ${autorole.roleId}) was not found on this server.`, flags: 64 });
|
|
}
|
|
},
|
|
};
|