small fixes and other

This commit is contained in:
The Foxon 2023-07-14 04:25:20 +12:00
parent b4742392a9
commit 26258ba518
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,29 @@
import { CacheType, ChatInputCommandInteraction, Message, PermissionFlagsBits, SlashCommandBuilder } from 'discord.js';
import ConfigController from '../controller/ConfigController';
import EcoController from '../controller/EcoController';
import { Command } from '.';
export default {
data: new SlashCommandBuilder()
.setName('remove_link')
.setDescription('Remove link Discord and Game accaunt')
.setDescriptionLocalization("ru", "Связь Discord и Игрового аккаунта")
.addUserOption(opt => opt.setName("user").setDescription("Discord user").setRequired(true)),
async execute(interaction) {
var user = interaction.options.getUser('user')
await interaction.deferReply({ ephemeral: true })
try {
if (!!user) {
global.config.users.delete(user.id)
global.config.authCodes.delete(user.id)
await interaction.followUp("Связь удалена")
} else
await interaction.followUp("Пользователь не указан")
} catch (error) {
await interaction.editReply("Ошибка удаления связи")
console.log(error)
}
},
} as Command

View File

@ -2,6 +2,7 @@ import { CacheType, ChatInputCommandInteraction, Message, PermissionFlagsBits, S
import ConfigController from '../controller/ConfigController'; import ConfigController from '../controller/ConfigController';
import EcoController from '../controller/EcoController'; import EcoController from '../controller/EcoController';
import { Command } from '.'; import { Command } from '.';
import { userInfo } from 'os';
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -20,7 +21,11 @@ export default {
try { try {
if (user !== undefined) { if (user !== undefined) {
if (!message) { if (!global.config.usersInGame.filter(u => u.SlgId === user.SlgId || u.SteamId === user.SteamId).length) {
await interaction.followUp(`Ошибка отправки сообщения, повторите привязку аккаунта или повторите через 20 секунд`);
return
}
else if (!message) {
await interaction.followUp(`Ошибка отправки сообщения`); await interaction.followUp(`Ошибка отправки сообщения`);
return return
} }

View File

@ -8,6 +8,7 @@ import setChatChannelId from './setChatChannelId'
import throwChatTimestamp from './throwChatTimestamp' import throwChatTimestamp from './throwChatTimestamp'
import UserMessage from './UserMessage' import UserMessage from './UserMessage'
import Link from './Link' import Link from './Link'
import RemoveLink from './RemoveLink'
export type Command = { export type Command = {
data: SlashCommandBuilder; data: SlashCommandBuilder;
@ -26,5 +27,6 @@ commands.set(setChatChannelId.data.name, setChatChannelId)
commands.set(throwChatTimestamp.data.name, throwChatTimestamp) commands.set(throwChatTimestamp.data.name, throwChatTimestamp)
commands.set(UserMessage.data.name, UserMessage) commands.set(UserMessage.data.name, UserMessage)
commands.set(Link.data.name, Link) commands.set(Link.data.name, Link)
commands.set(RemoveLink.data.name, RemoveLink)
export default commands export default commands