-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from Project-Coda/dev
Add Coda Strikes
- Loading branch information
Showing
8 changed files
with
223 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { SlashCommandBuilder } = require('@discordjs/builders'); | ||
const embedcreator = require('../embed.js'); | ||
const { ban } = require('../utilities/ban.js'); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('cban') | ||
.setDescription('Bans a user from the server') | ||
.addUserOption(option => | ||
option.setName('user') | ||
.setDescription('User you want to ban') | ||
.setRequired(true)) | ||
.addStringOption(option => | ||
option.setName('reason') | ||
.setDescription('Reason for the ban') | ||
.setRequired(true)), | ||
|
||
async execute(interaction) { | ||
try { | ||
// Limit command to Founders and Mods | ||
if (!(interaction.member.roles.cache.has(env.discord.admin_role) || interaction.member.roles.cache.has(env.discord.mod_role))) { | ||
global.client.channels.cache.get(env.discord.logs_channel).send({ | ||
embeds: [embedcreator.setembed( | ||
{ | ||
title: 'Incident Detected', | ||
description: `${interaction.member.user} tried to use the cban command but did not have the correct role.`, | ||
color: 0xe74c3c, | ||
}, | ||
)], | ||
}, | ||
); | ||
return interaction.reply({ | ||
embeds: [embedcreator.setembed( | ||
{ | ||
title: 'Incident Reported', | ||
description: 'You do not have permission to use this command. This incident has been reported.', | ||
color: 0xe74c3c, | ||
}, | ||
), | ||
], ephemeral: true, | ||
}); | ||
} | ||
const user = interaction.options.getUser('user'); | ||
const reason = interaction.options.getString('reason'); | ||
const userID = user.id; | ||
await ban(userID, reason); | ||
const embed = await embedcreator.setembed( | ||
{ | ||
title: 'User Banned', | ||
description: `User ${user.username} has been banned for ${reason}`, | ||
color: 0xe74c3c, | ||
}, | ||
); | ||
await interaction.reply({ embeds: [embed], ephemeral: true }); | ||
} | ||
catch (err) { | ||
console.log(err); | ||
embedcreator.sendError(err); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const mariadb = require('../db.js'); | ||
const embedcreator = require('../embed.js'); | ||
const env = require('../env.js'); | ||
async function ban(userID, message) { | ||
try { | ||
// if the user has 3 strikes, delete them from the database and ban them | ||
db = await mariadb.getConnection(); | ||
await db.query('DELETE FROM coda_strikes WHERE user_id = ?', [userID]); | ||
db.end(); | ||
} | ||
catch (err) { | ||
console.log(err); | ||
} | ||
// ban the user | ||
const user = await global.client.users.fetch(userID); | ||
try { | ||
embed = await embedcreator.setembed( | ||
{ | ||
title: 'You have been banned from the server', | ||
description: 'If you believe this is in error, fill out the fourm and we will review your case, within 24 hours.', | ||
color: 0xe74c3c, | ||
fields: [ | ||
{ | ||
name: 'Ban Appeal Form', | ||
value: env.discord.ban_appeal_form, | ||
}, | ||
], | ||
}, | ||
); | ||
await user.send({ embeds: [embed] }); | ||
} | ||
catch (err) { | ||
console.log(err); | ||
embedcreator.sendError(err); | ||
} | ||
const guild = await global.client.guilds.fetch(env.discord.guild); | ||
const member = await guild.members.fetch(userID); | ||
await member.ban({ deleteMessageSeconds: 604800, reason: message }); | ||
} | ||
module.exports = { | ||
ban, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters