mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 08:20:58 -05:00
add softban cmd and moderation improvements
This commit is contained in:
parent
75e8dcd272
commit
4cf327d2d0
@ -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}`;
|
||||
|
@ -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'))
|
||||
}
|
@ -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'))
|
||||
}
|
17
src/commands/softban.ts
Normal file
17
src/commands/softban.ts
Normal file
@ -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'))
|
||||
}
|
@ -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'))
|
||||
}
|
@ -7,7 +7,7 @@ export default {
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
let msgArray: Array<string> = [];
|
||||
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]})
|
||||
|
@ -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}`;
|
||||
|
Loading…
Reference in New Issue
Block a user