This repository has been archived by the owner on Oct 29, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
b306726
commit d894b38
Showing
3 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js') | ||
const warnModel = require("../../models/WarningDB") | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("remove-warn") | ||
.setDescription("remove warn a member") | ||
.addStringOption(options => options.setName("warnid").setDescription("warnid that you want to delete").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), | ||
async execute(interaction, client) { | ||
const warnid = interaction.options.getString("warnid") | ||
|
||
const data = await warnModel.findById(warnid) | ||
|
||
if (!data) return interaction.reply({content: `${warnid} is not a valid id`, ephemeral: true}) | ||
|
||
data.delete() | ||
|
||
const user = interaction.guild.members.cache.get(data.UserID) | ||
return interaction.reply({content: `Removed 1 of ${user}'s warnings`, ephemeral: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js') | ||
const warnModel = require("../../models/WarningDB") | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("warn") | ||
.setDescription("warn a member") | ||
.addUserOption(options => options.setName("target").setDescription("the member to warn").setRequired(true)) | ||
.addStringOption(options => options.setName("reason").setDescription("the reason").setRequired(false)) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), | ||
async execute(interaction, client) { | ||
const user = interaction.options.getUser("target") | ||
const reason = interaction.options.getString("reason") ||"No Reason" | ||
|
||
new warnModel({ | ||
UserID: user.id, | ||
GuildID: interaction.guildId, | ||
ModeratorID: interaction.user.id, | ||
Reason: reason, | ||
}).save() | ||
|
||
user.send(`You have been warned in ${interaction.guild.name}`).catch(console.log) | ||
|
||
interaction.reply({content: `${user} has been warned for ${reason}`, ephemeral: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require('discord.js') | ||
const warnModel = require("../../models/WarningDB") | ||
const moment = require("moment") | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("warnings") | ||
.setDescription("view all warns") | ||
.addUserOption(options => options.setName("target").setDescription("the member to warn").setRequired(true)) | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), | ||
async execute(interaction, client) { | ||
const user = interaction.options.getUser("target") | ||
|
||
const userWarnings = await warnModel.find({ | ||
UserID: user.id, | ||
GuildID: interaction.guildId, | ||
}) | ||
|
||
if (!userWarnings?.length) return interaction.reply({content: `${user} has no warnings in the server`, ephemeral: true}) | ||
|
||
const embedDescription = userWarnings.map((warn) => { | ||
const mods = interaction.guild.members.cache.get(warn.ModeratorID) | ||
|
||
return [ | ||
`WarnId: ${warn._id}`, | ||
`Moderator: ${mods || "Has left"}`, | ||
`Reason: ${warn.Reason}` | ||
].join("\n") | ||
}).join("\n\n") | ||
|
||
const embed = new EmbedBuilder() | ||
.setTitle(`${user.tag}'s warnings`) | ||
.setDescription(embedDescription) | ||
.setColor("Random") | ||
|
||
interaction.reply({embeds: [embed]}) | ||
}, | ||
}; |