nyx/commands/Config/prefix-reset.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const schema = require("../../models/guilds");
const prefix = require("../../config.json").prefix;
const { confirmation } = require("@reconlx/discord.js");
module.exports = {
name: "prefix-reset",
aliases: ["pr"],
description: 'Reset the prefix to "C." at the server',
UserPerm: "ADMINISTRATOR",
category: "Config",
run: async (client, message) => {
message.channel
.send("**Do you want to reset your prefix?**")
.then(async msg => {
const emoji = await confirmation(
msg,
message.author,
["✅", "❌"],
10000
);
if (emoji === "✅") {
msg.delete();
schema.findOne({ Guild: message.guild.id }, async (err, data) => {
if (data) {
data.Prefix = prefix;
await schema.findOneAndUpdate({ Guild: message.guild.id }, data);
}
});
message.channel.send(`The prefix has been reset to **${prefix}**`);
}
if (emoji === "❌") {
msg.delete();
message.channel.send("Cancelled.");
}
});
},
};