-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
186 additions
and
102 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
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 |
---|---|---|
@@ -1,81 +1,113 @@ | ||
"use strict"; | ||
|
||
const { SlashCommandBuilder } = require("@discordjs/builders"); | ||
const { CommandInteraction, Permissions, MessageEmbed, WebhookClient } = require("discord.js"); | ||
const { | ||
CommandInteraction, | ||
Permissions, | ||
MessageEmbed, | ||
WebhookClient, | ||
} = require("discord.js"); | ||
|
||
// Database queries | ||
const Guild = require("../../models/Logging/logs"); | ||
|
||
// Configs | ||
const emojis = require("../../../Controller/emojis/emojis"); | ||
|
||
module.exports.cooldown = { | ||
length: 10000, /* in ms */ | ||
users: new Set() | ||
length: 10000 /* in ms */, | ||
users: new Set(), | ||
}; | ||
|
||
/** | ||
* Runs the command. | ||
* @param {CommandInteraction} interaction The Command Interaciton | ||
* @param {any} utils Additional util | ||
*/ | ||
module.exports.run = async (interaction, utils) => | ||
{ | ||
try | ||
{ | ||
const target = interaction.options.getMember("target"); | ||
const reason = interaction.options.getString('reason') || "No reason provided"; | ||
|
||
if(!target) return interaction.reply({ content: "This User is invalid"}); | ||
|
||
let bandm = new MessageEmbed() | ||
.setColor("RED") | ||
.setDescription(`You have been banned from **${interaction.guild.name}**\nModerator: ${interaction.user.tag}\nReason: ${reason}`) | ||
await target.send({ embeds: [bandm] }); | ||
|
||
target.ban({ target }); | ||
|
||
let banmsg = new MessageEmbed() | ||
.setColor("GREEN") | ||
.setTitle(`${target.user.tag} Banned`) | ||
.setDescription(`Banned ${target.user.tag} from ${interaction.guild.name}\nModerator: ${interaction.user.tag}\nReason: ${reason}`) | ||
.setTimestamp() | ||
.setColor("GREEN") | ||
.setThumbnail(interaction.guild.iconURL({ dynamic: true })) | ||
.setImage(interaction.guild.iconURL({ dynamic: true })) | ||
|
||
const logs = new MessageEmbed() | ||
.setTitle("✅ | User banned") | ||
.setDescription(`User: ${target.user.tag}\nModerator: ${interaction.user.tag}\nReason: ${reason}`) | ||
.setTimestamp() | ||
.setColor("RED") | ||
|
||
// Log Channel | ||
const guildQuery = await Guild.findOne({ id: interaction.guild.id }) | ||
|
||
if(!guildQuery) return; | ||
if(guildQuery) { | ||
const webhookid = guildQuery.webhookid; | ||
const webhooktoken = guildQuery.webhooktoken; | ||
|
||
const webhookClient = new WebhookClient({ id: webhookid, token: webhooktoken }); | ||
|
||
webhookClient.send({ embeds: [logs]}) | ||
} | ||
|
||
await interaction.reply({ embeds: [banmsg], ephemeral: true }); | ||
return; | ||
module.exports.run = async (interaction, utils) => { | ||
try { | ||
const target = interaction.options.getMember("target"); | ||
const reason = | ||
interaction.options.getString("reason") || "No reason provided"; | ||
|
||
if (!target) return interaction.reply({ content: "This User is invalid" }); | ||
|
||
let bandm = new MessageEmbed() | ||
.setColor("RED") | ||
.setDescription( | ||
`You have been banned from **${interaction.guild.name}**\nModerator: ${interaction.user.tag}\nReason: ${reason}` | ||
); | ||
|
||
try { | ||
await target.send({ embeds: [bandm] }); | ||
} catch (error) { | ||
interaction.reply({ | ||
content: `${emojis.error} | Cannot send messages to this user.\nSuccessfully banned without sending warning through DMs.`, | ||
ephemeral: true, | ||
}); | ||
console.log(error); | ||
return target.ban({ target }); | ||
} | ||
catch (err) | ||
{ | ||
return Promise.reject(err); | ||
|
||
let banmsg = new MessageEmbed() | ||
.setColor("GREEN") | ||
.setTitle(`${target.user.tag} Banned`) | ||
.setDescription( | ||
`Banned ${target.user.tag} from ${interaction.guild.name}\nModerator: ${interaction.user.tag}\nReason: ${reason}` | ||
) | ||
.setTimestamp() | ||
.setColor("GREEN") | ||
.setThumbnail(interaction.guild.iconURL({ dynamic: true })) | ||
.setImage(interaction.guild.iconURL({ dynamic: true })); | ||
|
||
const logs = new MessageEmbed() | ||
.setTitle("✅ | User banned") | ||
.setDescription( | ||
`User: ${target.user.tag}\nModerator: ${interaction.user.tag}\nReason: ${reason}` | ||
) | ||
.setTimestamp() | ||
.setColor("RED"); | ||
|
||
// Log Channel | ||
const guildQuery = await Guild.findOne({ id: interaction.guild.id }); | ||
|
||
if (!guildQuery) return; | ||
if (guildQuery) { | ||
const webhookid = guildQuery.webhookid; | ||
const webhooktoken = guildQuery.webhooktoken; | ||
|
||
const webhookClient = new WebhookClient({ | ||
id: webhookid, | ||
token: webhooktoken, | ||
}); | ||
|
||
webhookClient.send({ embeds: [logs] }); | ||
} | ||
|
||
await interaction.reply({ embeds: [banmsg], ephemeral: true }); | ||
return; | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}; | ||
|
||
module.exports.permissions = { | ||
clientPermissions: [Permissions.FLAGS.ADMINISTRATOR], | ||
userPermissions: [Permissions.FLAGS.ADMINISTRATOR] | ||
clientPermissions: [Permissions.FLAGS.ADMINISTRATOR], | ||
userPermissions: [Permissions.FLAGS.ADMINISTRATOR], | ||
}; | ||
|
||
module.exports.data = new SlashCommandBuilder() | ||
.setName("ban") | ||
.setDescription("Ban a user") | ||
.addUserOption(option => option.setName("target").setDescription("Select the User to ban").setRequired(true)) | ||
.addStringOption(option => option.setName('reason').setDescription("Provide a Reason to Ban").setRequired(true)) | ||
.setName("ban") | ||
.setDescription("Ban a user") | ||
.addUserOption((option) => | ||
option | ||
.setName("target") | ||
.setDescription("Select the User to ban") | ||
.setRequired(true) | ||
) | ||
.addStringOption((option) => | ||
option | ||
.setName("reason") | ||
.setDescription("Provide a Reason to Ban") | ||
.setRequired(true) | ||
); |
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
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
Oops, something went wrong.