1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 00:10:58 -05:00

Update client.ts

This commit is contained in:
toast-ts 2023-03-04 12:19:50 -08:00
parent b2bac41acd
commit ee5378e374

View File

@ -159,14 +159,14 @@ export default class TClient extends Client {
async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){ async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod"); if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod");
const time = interaction.options.getString('time') as string; const time = interaction.options.getString('time') ?? undefined;
const reason = interaction.options.getString('reason') ?? 'Reason unspecified'; const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
const GuildMember = interaction.options.getMember('member') as Discord.GuildMember; const GuildMember = interaction.options.getMember('member') ?? undefined;
const User = interaction.options.getUser('member') as Discord.User; const User = interaction.options.getUser('member', true);
if (interaction.user.id == User.id) return interaction.reply(`You cannot ${type} yourself.`); if (interaction.user.id == User.id) return interaction.reply(`You cannot ${type} yourself.`);
if (!GuildMember && type != 'ban') return interaction.reply(`You cannot ${type} someone who is not in the server.`); if (!GuildMember && type != 'ban') return interaction.reply(`You cannot ${type} someone who is not in the server.`);
if (GuildMember.user.bot) return interaction.reply(`You cannot ${type} a bot!`); if (User.bot) return interaction.reply(`You cannot ${type} a bot!`);
await interaction.deferReply(); await interaction.deferReply();
await client.punishments.addPunishment(type, { time, interaction }, interaction.user.id, reason, User, GuildMember); await client.punishments.addPunishment(type, { time, interaction }, interaction.user.id, reason, User, GuildMember);