mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-29 14:11:02 +00:00
feat(bot-discord): moderation commands
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export function checkForPerms(config, member) {
|
||||
for (let role in config.discord.trainRoles) {
|
||||
for (const role in config.discord.modRoles) {
|
||||
if (member.roles.cache.get(role)) {
|
||||
return true;
|
||||
}
|
||||
8
apps/bot-discord/src/utils/checkSupporterPerms.js
Normal file
8
apps/bot-discord/src/utils/checkSupporterPerms.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export function checkForPerms(config, member) {
|
||||
for (const role in config.discord.trainRoles) {
|
||||
if (member.roles.cache.get(role)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
33
apps/bot-discord/src/utils/reportToLogs.js
Normal file
33
apps/bot-discord/src/utils/reportToLogs.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { EmbedBuilder, messageLink } from 'discord.js';
|
||||
|
||||
export default async function reportToLogs(config, client, action, message, { reason, expire, actionTo, actionBy }, channel) {
|
||||
const channel = await client.channels.fetch(config.logs.channelId);
|
||||
const thread = await channel.threads.fetch(config.logs.threadId);
|
||||
|
||||
const actionEmbed = new EmbedBuilder()
|
||||
.setThumbnail(actionTo.user.avatarURL());
|
||||
|
||||
const fields = [
|
||||
{ name: 'Action', value: `${actionTo.toString()} was ${action} by ${actionBy.toString()}` }
|
||||
];
|
||||
|
||||
if (action === 'banned' || action === 'muted') fields.push({
|
||||
name: 'Reason',
|
||||
value: reason ? reason : 'No reason provided'
|
||||
});
|
||||
|
||||
if (expire) fields.push({ name: 'Expires', value: `<t:${expire}:F>`});
|
||||
|
||||
if (!message) fields.push({ name: 'Reference', value: `[Jump to message](${messageLink(
|
||||
message.channelId,
|
||||
message.id,
|
||||
message.guild.id)})`
|
||||
});
|
||||
|
||||
actionEmbed.setFields(fields);
|
||||
|
||||
if (channel) {
|
||||
const msg = await channel.send({ embeds: [actionEmbed] });
|
||||
reportToLogs(config, client, action, msg, { reason, expire, actionTo, actionBy });
|
||||
} else thread.send({ embeds: [actionEmbed] });
|
||||
}
|
||||
Reference in New Issue
Block a user