-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig toggle safeword.js
45 lines (41 loc) · 1.47 KB
/
config toggle safeword.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { SlashCommandBuilder } = require("@discordjs/builders")
const Enmap = require('enmap');
const settings = new Enmap({
name: "settings",
fetchAll: false,
autoFetch: true,
cloneLevel: 'deep',
});
const falsetrue = [
{ name: "Disable", value: 0 }, //
{ name: "Enable", value: 1 }, // Default
]
const run = async (client, interaction) => {
// get the bool for the toggle, and the server key
let toggle = interaction.options.getNumber("toggle")
let key = `${interaction.guild.id}`;
try {
settings.set(key, toggle, "toggleSafeword");
} catch (error) {
console.error('Error trying to toggle the safeword: ', error);
return interaction.reply('Error trying to toggle the safeword: ' + error + ', please yell at the developer because this is a serious issue.')
}
if (toggle === 1) interaction.reply(`Succesfully enabled the safeword`)
else return interaction.reply(`Succesfully disabled the safeword.`)
}
module.exports = {
data: new SlashCommandBuilder().setName("toggle-safeword").setDescription("Enables or disables the use of /safeword & /optout."),
name: "toggle-safeword",
description: "Enables or disables the use of /safeword & /optout.",
perm: "manageperms",
options: [
{
name: "toggle",
description: "Enables or disables the use of /safeword",
type: "NUMBER",
choices: falsetrue,
required: true
},
],
run
}