I did some work at school and need to save it hi github
oh also you're welcome mini, i changed the colours
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 2942844..3c4544e 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -227,7 +227,7 @@
// Check if Nucleus has permission to mute
if (! interaction.guild.me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
// Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || apply.id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
+ if ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot mute myself"
// Allow the owner to mute anyone
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index b91f065..8bec805 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -1,57 +1,53 @@
-import humanizeDuration from 'humanize-duration';
-import { CommandInteraction, GuildMember, TextChannel } from "discord.js";
+import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
-import keyValueList from "../../utils/generateKeyValueList.js";
-import confirmationMessage from "../../utils/confirmationMessage.js";
-import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import humanizeDuration from 'humanize-duration';
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("slowmode")
.setDescription("Manages slowmode in a channel")
- .addStringOption(option => option.setName("time").setDescription("The delay between messages").setRequired(false).addChoices([
- ["Off", "0"],
- ["5 seconds", "5"], ["10 seconds", "10"], ["15 seconds", "15"], ["30 seconds", "30"],
- ["1 minute", "60"], ["2 minutes", "120"], ["5 minutes", "300"], ["10 minutes", "600"],
- ["15 minutes", "900"], ["30 minutes", "1800"],
- ["1 hour", "3600"], ["2 hours", "7200"], ["6 hours", "21600"]
- ]))
+ .addIntegerOption(option => option.setName("seconds").setDescription("The seconds between messages").setRequired(false))
+ .addIntegerOption(option => option.setName("minutes").setDescription("The minutes between messages").setRequired(false))
+ .addIntegerOption(option => option.setName("hours").setDescription("The hours between messages").setRequired(false))
-const callback = async (interaction: CommandInteraction) => {
- let time = parseInt(interaction.options.getString("time") ?? "0");
- if (time === 0 && (interaction.channel as TextChannel).rateLimitPerUser === 0) { time = 10 }
+const callback = (interaction: CommandInteraction) => {
+ let seconds = interaction.option.getInteger("seconds")
+ let minutes = interaction.option.getInteger("minutes")
+ let hours = interaction.option.getInteger("hours")
+ let totalTime = seconds + (minutes * 60) + (hours * 60 * 60)
+
let confirmation = await new confirmationMessage(interaction)
- .setEmoji("CHANNEL.SLOWMODE.RED")
+ .setEmoji("PUNISH.SLOWMODE.RED")
.setTitle("Slowmode")
.setDescription(keyValueList({
- "time": time ? humanizeDuration(time * 1000, { round: true }) : "No delay",
+ "delay": `${totalTime ? humanizeDuration(totalTime * 1000) : "*No delay*"}`
})
- + `Are you sure you want to set the slowmode in this channel?`)
+ + `Are you sure you want to enable slowmode in this channel?`)
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
if (confirmation.success) {
try {
- (interaction.channel as TextChannel).setRateLimitPerUser(time)
- } catch (e) {
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.RED")
+ await interaction.setRateLimitPerUser(totalTime, "Nucleus slowmode")
+ } catch {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("PUNISH.SLOWMODE.RED")
.setTitle(`Slowmode`)
- .setDescription("An error occurred while setting the slowmode")
+ .setDescription("Something went wrong and the slowmode could not be set.")
.setStatus("Danger")
], components: []})
}
await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji(`CHANNEL.SLOWMODE.GREEN`)
+ .setEmoji("PUNISH.NICKNAME.GREEN")
.setTitle(`Slowmode`)
.setDescription("The channel slowmode was set successfully")
.setStatus("Success")
], components: []})
} else {
await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setEmoji("CHANNEL.SLOWMODE.GREEN")
+ .setEmoji("PUNISH.SLOWMODE.GREEN")
.setTitle(`Slowmode`)
.setDescription("No changes were made")
.setStatus("Success")
@@ -61,9 +57,12 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
- // Check if Nucleus can set the slowmode
- if (! interaction.guild.me.permissions.has("MANAGE_CHANNELS")) throw "I do not have the `manage_channels` permission";
- // Check if the user has manage_channel permission
+ let me = (interaction.guild.me as GuildMember)
+ // Check if Nucleus can edit the channel
+ if (! interaction.guild.me.permission.has("MANAGE_CHANNELS")) throw "I do not have permission to edit this channel"
+ // Allow the owner to set any channel
+ if (member.id == interaction.guild.ownerId) return true
+ // Check if the user has manage_channels permission
if (! member.permissions.has("MANAGE_CHANNELS")) throw "You do not have the `manage_channels` permission";
// Allow slowmode
return true
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 26815eb..8ea3ec1 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -88,6 +88,7 @@
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
let member = (interaction.member as GuildMember)
+ let me = (interaction.guild.me as GuildMember)
// Check if Nucleus can unban members
if (! interaction.guild.me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
// Allow the owner to unban anyone
diff --git a/src/commands/mod/unmute.ts b/src/commands/mod/unmute.ts
index 2d630ea..163c059 100644
--- a/src/commands/mod/unmute.ts
+++ b/src/commands/mod/unmute.ts
@@ -89,7 +89,7 @@
// Check if Nucleus has permission to unmute
if (! interaction.guild.me.permissions.has("MODERATE_MEMBERS")) throw "I do not have the `moderate_members` permission";
// Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
+ if ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot unmute an admin or the owner"
// Allow the owner to unmute anyone
if (member.id == interaction.guild.ownerId) return true
// Check if the user has moderate_members permission
diff --git a/src/commands/mod/unnamed.ts b/src/commands/mod/unnamed.ts
index c2d5618..4c6a31e 100644
--- a/src/commands/mod/unnamed.ts
+++ b/src/commands/mod/unnamed.ts
@@ -217,7 +217,7 @@
// Check if Nucleus has permission to UNNAMED
if (! interaction.guild.me.permissions.has("MANAGE_ROLES")) throw "I do not have the `manage_roles` permission";
// Do not allow the user to have admin or be the owner
- if (apply.permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
+ if ((interaction.options.getMember("user") as GuildMember).permissions.has("ADMINISTRATOR") || (interaction.options.getMember("user") as GuildMember).id == interaction.guild.ownerId) throw "You cannot mute an admin or the owner"
// Do not allow muting Nucleus
if (member.id == interaction.guild.me.id) throw "I cannot UNNAMED myself"
// Allow the owner to UNNAMED anyone