@@ -1,24 +1,34 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const getuuid = require("../utils/functions");
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const getuuid = require('../utils/functions');
|
||||
|
||||
module.exports = {
|
||||
name: "dev-info",
|
||||
description: "Test command for the bot.",
|
||||
type: "slash",
|
||||
name: 'dev-info',
|
||||
description: 'Test command for the bot.',
|
||||
type: 'slash',
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("dev-info")
|
||||
.setDescription("Test command for the bot.")
|
||||
.addStringOption((option) => option.setName("test").setDescription("Test option."))
|
||||
.addStringOption((option) => option.setName("test2").setDescription("Test option."))
|
||||
.addStringOption((option) => option.setName("test3").setDescription("Test option."))
|
||||
.setName('dev-info')
|
||||
.setDescription('Test command for the bot.')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('test')
|
||||
.setDescription('Test option.'))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('test2')
|
||||
.setDescription('Test option.'))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('test3')
|
||||
.setDescription('Test option.'))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
async execute(interaction) {
|
||||
const test = interaction.options.getString("test");
|
||||
const test2 = interaction.options.getString("test2");
|
||||
const test3 = interaction.options.getString("test3");
|
||||
|
||||
const test = interaction.options.getString('test');
|
||||
const test2 = interaction.options.getString('test2');
|
||||
const test3 = interaction.options.getString('test3');
|
||||
|
||||
const message = await interaction.channel.messages.fetch(test);
|
||||
const embed = message.embeds[0];
|
||||
@@ -27,6 +37,6 @@ module.exports = {
|
||||
|
||||
console.log(field1.value);
|
||||
|
||||
await interaction.reply({ content: "Test command.", ephemeral: true });
|
||||
},
|
||||
await interaction.reply({ content: 'Test command.', ephemeral: true });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,87 +1,88 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require("discord.js");
|
||||
const env = require("dotenv").config();
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js');
|
||||
const env = require('dotenv').config();
|
||||
const dev = process.env.DEV;
|
||||
const { color } = require("../config/options.json");
|
||||
const { admin, helper, muted } = require("../config/roles.json");
|
||||
const { staffOtherChannel } = require("../config/options.json");
|
||||
const { color } = require('../config/options.json');
|
||||
const { admin, helper, muted } = require('../config/roles.json');
|
||||
const { staffOtherChannel } = require('../config/options.json');
|
||||
|
||||
module.exports = {
|
||||
name: "mute",
|
||||
description: "Mute a user",
|
||||
type: "slash",
|
||||
name: 'mute',
|
||||
description: 'Mute a user',
|
||||
type: 'slash',
|
||||
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("mute")
|
||||
.setDescription("Mute a user")
|
||||
.addUserOption((option) => option.setName("user").setDescription("The user to mute").setRequired(true))
|
||||
.addStringOption((option) => option.setName("reason").setDescription("The reason for the mute"))
|
||||
.addStringOption((option) => option.setName("duration").setDescription("The duration of the mute"))
|
||||
.setName('mute')
|
||||
.setDescription('Mute a user')
|
||||
.addUserOption(option =>
|
||||
option
|
||||
.setName('user')
|
||||
.setDescription('The user to mute')
|
||||
.setRequired(true))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('reason')
|
||||
.setDescription('The reason for the mute'))
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName('duration')
|
||||
.setDescription('The duration of the mute'))
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.setDMPermission(false),
|
||||
|
||||
async execute(interaction) {
|
||||
const member1 = interaction.options.getUser("user");
|
||||
const member = interaction.guild.members.cache.get(member1.id);
|
||||
const reason = interaction.options.getString("reason") ?? "No reason provided";
|
||||
const duration = interaction.options.getString("duration");
|
||||
const guild = interaction.guild;
|
||||
const embedColor = Number(color.replace("#", "0x"));
|
||||
|
||||
const userRoles = await guild.members
|
||||
.fetch(interaction.user.id)
|
||||
.then((member) => member.roles.cache.map((role) => role.id));
|
||||
const memberRoles = await guild.members
|
||||
.fetch(member1.id)
|
||||
.then((member) => member.roles.cache.map((role) => role.id));
|
||||
const member1 = interaction.options.getUser('user');
|
||||
const member = interaction.guild.members.cache.get(member1.id);
|
||||
const reason = interaction.options.getString('reason') ?? 'No reason provided';
|
||||
const duration = interaction.options.getString('duration');
|
||||
const guild = interaction.guild;
|
||||
const embedColor = Number(color.replace('#', '0x'));
|
||||
|
||||
const userRoles = await guild.members.fetch(interaction.user.id).then(member => member.roles.cache.map(role => role.id));
|
||||
const memberRoles = await guild.members.fetch(member1.id).then(member => member.roles.cache.map(role => role.id));
|
||||
|
||||
await interaction.deferReply({});
|
||||
|
||||
if (!userRoles.includes(admin || helper)) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "You don't have permission to use this command.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
embeds: [{
|
||||
description: "You don't have permission to use this command.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
});
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (member.id === interaction.user.id) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "You can't mute yourself.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
embeds: [{
|
||||
description: "You can't mute yourself.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
});
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (member.id === dev) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "You can't mute my developer.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
embeds: [{
|
||||
description: "You can't mute my developer.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
});
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
// if (memberRoles.includes(admin) || memberRoles.includes(helper)) {
|
||||
@@ -101,27 +102,25 @@ module.exports = {
|
||||
if (!duration) {
|
||||
await member.roles.add(muted, reason);
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "Successfully muted " + userMention(member1.id) + " forever.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
return;
|
||||
embeds: [{
|
||||
description: "Successfully muted " + userMention(member1.id) + " forever.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
console.log(duration);
|
||||
|
||||
const weeks = duration.replace(/[0-9][dhms]/g, "").replace(/w/g, "");
|
||||
const days = duration.replace(/[0-9][whms]/g, "").replace(/d/g, "");
|
||||
const hours = duration.replace(/[0-9][wdms]/g, "").replace(/h/g, "");
|
||||
const minutes = duration.replace(/[0-9][wdhs]/g, "").replace(/m/g, "");
|
||||
const seconds = duration.replace(/[0-9][wdhm]/g, "").replace(/s/g, "");
|
||||
const weeks = duration.replace(/[0-9][dhms]/g, '').replace(/w/g, '')
|
||||
const days = duration.replace(/[0-9][whms]/g, '').replace(/d/g, '')
|
||||
const hours = duration.replace(/[0-9][wdms]/g, '').replace(/h/g, '')
|
||||
const minutes = duration.replace(/[0-9][wdhs]/g, '').replace(/m/g, '')
|
||||
const seconds = duration.replace(/[0-9][wdhm]/g, '').replace(/s/g, '')
|
||||
|
||||
const nweeks = Number(weeks) ?? 0;
|
||||
const ndays = Number(days) ?? 0;
|
||||
@@ -130,25 +129,18 @@ module.exports = {
|
||||
const nseconds = Number(seconds) ?? 0;
|
||||
|
||||
const time = nweeks * 604800000 + ndays * 86400000 + nhours * 3600000 + nminutes * 60000 + nseconds * 1000;
|
||||
const mutedTime =
|
||||
(nweeks > 0 ? nweeks + " week(s), " : "") +
|
||||
(ndays > 0 ? ndays + " day(s), " : "") +
|
||||
(nhours > 0 ? nhours + " hour(s), " : "") +
|
||||
(nminutes > 0 ? nminutes + " minute(s), " : "") +
|
||||
(nseconds > 0 ? nseconds + " second(s)" : "");
|
||||
const mutedTime = (nweeks > 0 ? nweeks + " week(s), " : "") + (ndays > 0 ? ndays + " day(s), " : "") + (nhours > 0 ? nhours + " hour(s), " : "") + (nminutes > 0 ? nminutes + " minute(s), " : "") + (nseconds > 0 ? nseconds + " second(s)" : "");
|
||||
|
||||
await member.roles.add(muted, reason);
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
embeds: [{
|
||||
description: "Successfully muted " + userMention(member1.id) + " for " + mutedTime + ".",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
const logChannel = interaction.guild.channels.cache.get(staffOtherChannel);
|
||||
@@ -156,17 +148,15 @@ module.exports = {
|
||||
setTimeout(async () => {
|
||||
await member.roles.remove(muted, "Mute duration has ended.");
|
||||
await logChannel.send({
|
||||
embeds: [
|
||||
{
|
||||
description: userMention(member1.id) + " has been unmuted.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + member1.id,
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true }),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
embeds: [{
|
||||
description: userMention(member1.id) + " has been unmuted.",
|
||||
color: embedColor,
|
||||
footer: {
|
||||
text: "ID: " + member1.id,
|
||||
icon_url: interaction.guild.iconURL({ dynamic: true })
|
||||
}
|
||||
}]
|
||||
})
|
||||
}, time);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user