eco-discord-bot/src/commands/setChatChannelId.ts

35 lines
1.0 KiB
TypeScript

import { PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import { Command } from '.';
// const adminPermissions = new PermissionsBitField('Administrator');
export default {
data: new SlashCommandBuilder()
.setName('set_chat_channel')
.setDescription('set chat channel')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true })
try {
if (!interaction.channel?.isTextBased()) throw new Error()
global.config.chatChannelId = interaction.channelId
if (!!global.config.chatChannelId) {
await interaction.followUp("Успешно")
} else {
await interaction.followUp("Ошибка синхронизации")
}
return
} catch (error) {
if (interaction.replied)
await interaction.editReply("Ошибка синхронизации")
else
await interaction.followUp("Ошибка синхронизации")
console.log(error)
}
},
} as Command