diff --git a/src/client.ts b/src/client.ts index 202575d..be5b075 100644 --- a/src/client.ts +++ b/src/client.ts @@ -230,7 +230,6 @@ export class TClient extends Client { } } - //class class bannedWords extends Database { client: TClient; @@ -283,7 +282,7 @@ class punishments extends Database { const guild = member.guild; const softbanData:Punishment={type, id: this.createId(), member: member.user.id, moderator, time: now}; const dm2 = Discord.Message = await member.send(`You've been softbanned from ${member.guild.name} ${timeInMillis ? `for ${this.client.formatTime(timeInMillis, 4, {longNames: true, commas: true})}` : 'forever'} for reason \`${reason || 'Reason unspecified'}\` (Case #${softbanData.id})`).catch(()=>{return interaction.channel.send('Failed to DM user.')}) - const softbanResult = await member.ban({deleteMessageDays: 3, reason: `${reason || 'Reason unspecified'} | Case #${softbanData.id}`}).catch((err:Error)=>err.message); + const softbanResult = await member.ban({deleteMessageSeconds: 345600, reason: `${reason || 'Reason unspecified'} | Case #${softbanData.id}`}).catch((err:Error)=>err.message); if (typeof softbanResult === 'string') { dm2.delete(); return `Softban was unsuccessful: ${softbanResult}`; diff --git a/src/commands/ban.ts b/src/commands/ban.ts index 1083fda..896300d 100644 --- a/src/commands/ban.ts +++ b/src/commands/ban.ts @@ -13,10 +13,8 @@ export default { .setRequired(true)) .addStringOption((opt)=>opt .setName('time') - .setDescription('How long the ban will be?') - .setRequired(false)) + .setDescription('How long the ban will be?')) .addStringOption((opt)=>opt .setName('reason') - .setDescription('Reason for the ban') - .setRequired(false)) + .setDescription('Reason for the ban')) } \ No newline at end of file diff --git a/src/commands/kick.ts b/src/commands/kick.ts index 168017c..10de051 100644 --- a/src/commands/kick.ts +++ b/src/commands/kick.ts @@ -13,6 +13,5 @@ export default { .setRequired(true)) .addStringOption((opt)=>opt .setName('reason') - .setDescription('Reason for the kick') - .setRequired(false)) + .setDescription('Reason for the kick')) } \ No newline at end of file diff --git a/src/commands/softban.ts b/src/commands/softban.ts new file mode 100644 index 0000000..ca8dbd4 --- /dev/null +++ b/src/commands/softban.ts @@ -0,0 +1,17 @@ +import Discord,{SlashCommandBuilder} from 'discord.js'; +import { TClient } from 'src/client'; +export default { + async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){ + client.punish(client, interaction, 'softban'); + }, + data: new SlashCommandBuilder() + .setName('softban') + .setDescription('Softban a member from the server') + .addUserOption((opt)=>opt + .setName('member') + .setDescription('Which member to softban?') + .setRequired(true)) + .addStringOption((opt)=>opt + .setName('reason') + .setDescription('Reason for the softban')) +} \ No newline at end of file diff --git a/src/commands/unpunish.ts b/src/commands/unpunish.ts index f8894bb..315219f 100644 --- a/src/commands/unpunish.ts +++ b/src/commands/unpunish.ts @@ -13,6 +13,5 @@ export default { .setRequired(true)) .addStringOption((opt)=>opt .setName('reason') - .setDescription('Reason for removing the punishment') - .setRequired(false)) + .setDescription('Reason for removing the punishment')) } \ No newline at end of file diff --git a/src/events/messageDeleteBulk.ts b/src/events/messageDeleteBulk.ts index 7e6c006..4df03c2 100644 --- a/src/events/messageDeleteBulk.ts +++ b/src/events/messageDeleteBulk.ts @@ -7,7 +7,7 @@ export default { if (!client.config.botSwitches.logs) return; let msgArray: Array = []; messages.forEach((m)=>{ - msgArray.push(`${m.author.username}: ${m.content}`); + msgArray.push(`${m.author?.username}: ${m.content}`); }); const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setTitle(`${messages.size} messages were purged`).setDescription(`\`\`\`${msgArray.reverse().join('\n')}\`\`\``.slice(0,3900)).addFields({name: 'Channel', value: `<#${(messages.first() as Discord.Message).channel.id}>`}); channel.send({embeds: [embed]}) diff --git a/src/index.ts b/src/index.ts index 21b5cc3..33ef719 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,7 @@ client.on('ready', async()=>{ }, 500000); console.log(`${client.user.tag} has logged into Discord API and now ready for operation`); console.log(client.config.botSwitches); - (client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``); + //(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``); // Event handler const eventFiles = fs.readdirSync('src/events').filter(file=>file.endsWith('.ts')); @@ -210,7 +210,7 @@ Object.assign(client.punishments,{ const guild = member.guild; const softbanData: Punishment = {type, id: this.createId(), member: member.user.id, moderator, time: now}; const dm2 = await member.send(`You've been softbanned from ${member.guild.name} for reason \`${reason || 'Reason unspecified'}\` (Case #${softbanData.id})`).catch(err=>setTimeout(()=>interaction.channel.send(`Failed to DM <@${member.user.id}>.`), 500)); - const softbanResult = await member.ban({deleteMessageDays: 7, reason: `${reason || 'Reason unspecified'} | Case #${softbanData.id}`}).catch((err: Error)=>err.message); + const softbanResult = await member.ban({deleteMessageSeconds: 345600, reason: `${reason || 'Reason unspecified'} | Case #${softbanData.id}`}).catch((err: Error)=>err.message); if (typeof softbanResult === 'string'){ dm2.delete(); return `Softban was unsuccessful: ${softbanResult}`;