Start of context menus
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index db0d68b..0e76cba 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -49,6 +49,7 @@
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
+ if (!interaction.guild) return;
const { log, NucleusColors, renderUser, entry, renderDelta } = client.logger;
const user = interaction.options.getMember("user") as GuildMember;
const time = {
@@ -57,7 +58,7 @@
minutes: interaction.options.getInteger("minutes") ?? 0,
seconds: interaction.options.getInteger("seconds") ?? 0
};
- const config = await client.database.guilds.read(interaction.guild!.id);
+ const config = await client.database.guilds.read(interaction.guild.id);
let serverSettingsDescription = config.moderation.mute.timeout ? "given a timeout" : "";
if (config.moderation.mute.role)
serverSettingsDescription +=
@@ -187,9 +188,9 @@
.addCustomBoolean(
"appeal",
"Create appeal ticket",
- !(await areTicketsEnabled(interaction.guild!.id)),
+ !(await areTicketsEnabled(interaction.guild.id)),
async () =>
- await create(interaction.guild!, interaction.options.getUser("user")!, interaction.user, reason),
+ await create(interaction.guild, interaction.options.getUser("user")!, interaction.user, reason),
"An appeal ticket will be created when Confirm is clicked",
"CONTROL.TICKET",
createAppealTicket
@@ -226,7 +227,7 @@
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Muted")
.setDescription(
- `You have been muted in ${interaction.guild!.name}` +
+ `You have been muted in ${interaction.guild.name}` +
(reason
? ` for:\n> ${reason}`
: ".\n\n" +
@@ -267,7 +268,7 @@
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
await client.database.eventScheduler.schedule("naturalUnmute", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild!.id,
+ guild: interaction.guild.id,
user: user.id,
expires: new Date().getTime() + muteTime * 1000
});
@@ -280,7 +281,7 @@
if (config.moderation.mute.role !== null) {
await member.roles.add(config.moderation.mute.role);
await client.database.eventScheduler.schedule("unmuteRole", new Date().getTime() + muteTime * 1000, {
- guild: interaction.guild!.id,
+ guild: interaction.guild.id,
user: user.id,
role: config.moderation.mute.role
});
@@ -303,7 +304,7 @@
if (dmd && dm) await dm.delete();
return;
}
- await client.database.history.create("mute", interaction.guild!.id, member.user, interaction.user, reason);
+ await client.database.history.create("mute", interaction.guild.id, member.user, interaction.user, reason);
const failed = !dmd && notify;
await interaction.editReply({
embeds: [
@@ -342,7 +343,7 @@
reason: entry(reason, reason ? reason : "*No reason provided*")
},
hidden: {
- guild: interaction.guild!.id
+ guild: interaction.guild.id
}
};
log(data);
@@ -361,14 +362,15 @@
};
const check = (interaction: CommandInteraction) => {
+ if (!interaction.guild) return;
const member = interaction.member as GuildMember;
- const me = interaction.guild!.me!;
+ const me = interaction.guild.me!;
const apply = interaction.options.getMember("user") as GuildMember;
const memberPos = member.roles.cache.size > 1 ? member.roles.highest.position : 0;
const mePos = me.roles.cache.size > 1 ? me.roles.highest.position : 0;
const applyPos = apply.roles.cache.size > 1 ? apply.roles.highest.position : 0;
// Do not allow muting the owner
- if (member.id === interaction.guild!.ownerId) throw new Error("You cannot mute the owner of the server");
+ if (member.id === interaction.guild.ownerId) throw new Error("You cannot mute the owner of the server");
// Check if Nucleus can mute the member
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member");
// Check if Nucleus has permission to mute
@@ -376,7 +378,7 @@
// Do not allow muting Nucleus
if (member.id === me.id) throw new Error("I cannot mute myself");
// Allow the owner to mute anyone
- if (member.id === interaction.guild!.ownerId) return true;
+ if (member.id === interaction.guild.ownerId) return true;
// Check if the user has moderate_members permission
if (!member.permissions.has("MODERATE_MEMBERS"))
throw new Error("You do not have the *Moderate Members* permission");