38 lines
No EOL
1.4 KiB
TypeScript
38 lines
No EOL
1.4 KiB
TypeScript
import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
|
import { Command } from "../type/command";
|
|
import CardSetupFunction from "../Functions/CardSetupFunction";
|
|
import Config from "../database/entities/app/Config";
|
|
|
|
export default class Resync extends Command {
|
|
constructor() {
|
|
super();
|
|
|
|
super.CommandBuilder = new SlashCommandBuilder()
|
|
.setName('resync')
|
|
.setDescription('Resync the card database')
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
|
}
|
|
|
|
public override async execute(interaction: CommandInteraction<CacheType>) {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(',');
|
|
|
|
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
|
|
await interaction.reply("Only whitelisted users can use this command.");
|
|
return;
|
|
}
|
|
|
|
if (await CardSetupFunction.Execute()) {
|
|
if (await Config.GetValue('safemode') == "true") {
|
|
await Config.SetValue('safemode', 'false');
|
|
await interaction.reply("Resynced database and disabled safe mode.");
|
|
|
|
return;
|
|
}
|
|
await interaction.reply("Resynced database.");
|
|
} else {
|
|
await interaction.reply("Resync failed, safe mode has been activated until successful resync.");
|
|
}
|
|
}
|
|
} |