Coded wanted to host the liveshare

pull/11/head
PineaFan 3 years ago
parent 19dc9b8066
commit 5d98a4bcb7
No known key found for this signature in database
GPG Key ID: D404018735F488C9

@ -1,30 +0,0 @@
-rw-r--r-- 1 pineapplefan pineapplefan 2735 Dec 29 11:03 channelCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 3661 Dec 29 11:04 channelDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 7430 Nov 15 20:45 channelUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 960 Nov 15 20:39 commandError.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1097 Aug 8 21:15 emojiCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1184 Aug 8 21:15 emojiDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1183 Aug 8 21:15 emojiUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1849 Dec 29 11:04 guildBanAdd.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1558 Dec 29 11:04 guildBanRemove.ts
-rw-r--r-- 1 pineapplefan pineapplefan 267 Dec 29 11:04 guildCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 5553 Dec 29 11:04 guildMemberUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 3863 Jan 6 17:42 guildUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1710 Jan 6 18:38 interactionCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1482 Dec 29 11:04 inviteCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1471 Dec 29 11:04 inviteDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1387 Dec 29 11:04 memberJoin.ts
-rw-r--r-- 1 pineapplefan pineapplefan 3260 Jan 2 21:41 memberLeave.ts
-rw-r--r-- 1 pineapplefan pineapplefan 14919 Dec 29 11:04 messageCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 4907 Dec 29 11:04 ! messageDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 4907 Dec 29 11:04 ? messageEdit.ts: Check message publishing
-rw-r--r-- 1 pineapplefan pineapplefan 1268 Dec 29 11:04 roleCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1915 Dec 29 11:04 roleDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 2562 Dec 29 11:04 roleUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1262 Dec 29 11:04 stickerCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1349 Dec 29 11:04 stickerDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1272 Dec 29 11:04 stickerUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 1967 Dec 29 11:04 threadCreate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 2140 Dec 29 11:04 threadDelete.ts
-rw-r--r-- 1 pineapplefan pineapplefan 2464 Dec 29 11:04 threadUpdate.ts
-rw-r--r-- 1 pineapplefan pineapplefan 6352 Dec 29 11:04 webhookUpdate.ts

5094
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -5,7 +5,9 @@ import Discord, {
ActionRowBuilder, ActionRowBuilder,
ButtonBuilder, ButtonBuilder,
SelectMenuBuilder, SelectMenuBuilder,
ButtonStyle ButtonStyle,
StringSelectMenuBuilder,
APIMessageComponentEmoji
} from "discord.js"; } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@ -171,8 +173,8 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const all = true; const all = true;
while (true) { while (true) {
let count = 0; let count = 0;
const affected = []; const affected: GuildMember[] = [];
const members = interaction.guild.members.cache; const members = interaction.guild!.members.cache;
if (all) { if (all) {
members.forEach((member) => { members.forEach((member) => {
let applies = true; let applies = true;
@ -224,8 +226,8 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
.setStatus("Success") .setStatus("Success")
], ],
components: [ components: [
new ActionRowBuilder().addComponents([ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents([
new SelectMenuBuilder() new StringSelectMenuBuilder()
.setOptions( .setOptions(
filters.map((f, index) => ({ filters.map((f, index) => ({
label: (f.inverted ? "(Not) " : "") + f.name, label: (f.inverted ? "(Not) " : "") + f.name,
@ -237,18 +239,18 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
.setCustomId("select") .setCustomId("select")
.setPlaceholder("Remove a filter") .setPlaceholder("Remove a filter")
]), ]),
new ActionRowBuilder().addComponents([ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder() new ButtonBuilder()
.setLabel("Apply") .setLabel("Apply")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setCustomId("apply") .setCustomId("apply")
.setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id"))) .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id"))! as APIMessageComponentEmoji)
.setDisabled(affected.length === 0), .setDisabled(affected.length === 0),
new ButtonBuilder() new ButtonBuilder()
.setLabel("Add filter") .setLabel("Add filter")
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setCustomId("add") .setCustomId("add")
.setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id"))) .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id"))! as APIMessageComponentEmoji)
.setDisabled(filters.length >= 25) .setDisabled(filters.length >= 25)
]) ])
] ]
@ -260,12 +262,12 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const check = async (interaction: CommandInteraction) => { const check = async (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember; const member = interaction.member as GuildMember;
const me = interaction.guild.me!; const me = interaction.guild!.members.me!;
if (!me.permissions.has("MANAGE_ROLES")) throw new Error("I do not have the *Manage Roles* permission"); if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
// Allow the owner to role anyone // Allow the owner to role anyone
if (member.id === interaction.guild.ownerId) return true; if (member.id === interaction.guild!.ownerId) return true;
// Check if the user has manage_roles permission // Check if the user has manage_roles permission
if (!member.permissions.has("MANAGE_ROLES")) throw new Error("You do not have the *Manage Roles* permission"); if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
// Allow role // Allow role
return true; return true;
}; };

@ -181,19 +181,19 @@ const check = async (interaction: CommandInteraction) => {
apply = apply as User apply = apply as User
} }
// Do not allow banning the owner // Do not allow banning the owner
if (member.id === interaction.guild.ownerId) throw new Error("You cannot ban the owner of the server"); if (member.id === interaction.guild.ownerId) return "You cannot ban the owner of the server";
// Check if Nucleus can ban the member // Check if Nucleus can ban the member
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member"); if (!(mePos > applyPos)) return "I do not have a role higher than that member";
// Check if Nucleus has permission to ban // Check if Nucleus has permission to ban
if (!me.permissions.has("BanMembers")) throw new Error("I do not have the *Ban Members* permission"); if (!me.permissions.has("BanMembers")) return "I do not have the *Ban Members* permission";
// Do not allow banning Nucleus // Do not allow banning Nucleus
if (member.id === me.id) throw new Error("I cannot ban myself"); if (member.id === me.id) return "I cannot ban myself";
// Allow the owner to ban anyone // Allow the owner to ban anyone
if (member.id === interaction.guild.ownerId) return true; if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission // Check if the user has ban_members permission
if (!member.permissions.has("BanMembers")) throw new Error("You do not have the *Ban Members* permission"); if (!member.permissions.has("BanMembers")) return "You do not have the *Ban Members* permission";
// Check if the user is below on the role list // Check if the user is below on the role list
if (!(memberPos > applyPos)) throw new Error("You do not have a role higher than that member"); if (!(memberPos > applyPos)) return "You do not have a role higher than that member";
// Allow ban // Allow ban
return true; return true;
}; };

@ -182,19 +182,19 @@ const check = async (interaction: CommandInteraction) => {
apply = apply as User apply = apply as User
} }
// Do not allow banning the owner // Do not allow banning the owner
if (member.id === interaction.guild.ownerId) throw new Error("You cannot softban the owner of the server"); if (member.id === interaction.guild.ownerId) return "You cannot softban the owner of the server";
// Check if Nucleus can ban the member // Check if Nucleus can ban the member
if (!(mePos > applyPos)) throw new Error("I do not have a role higher than that member"); if (!(mePos > applyPos)) return "I do not have a role higher than that member";
// Check if Nucleus has permission to ban // Check if Nucleus has permission to ban
if (!me.permissions.has("BanMembers")) throw new Error("I do not have the *Ban Members* permission"); if (!me.permissions.has("BanMembers")) return "I do not have the *Ban Members* permission";
// Do not allow banning Nucleus // Do not allow banning Nucleus
if (member.id === me.id) throw new Error("I cannot softban myself"); if (member.id === me.id) return "I cannot softban myself";
// Allow the owner to ban anyone // Allow the owner to ban anyone
if (member.id === interaction.guild.ownerId) return true; if (member.id === interaction.guild.ownerId) return true;
// Check if the user has ban_members permission // Check if the user has ban_members permission
if (!member.permissions.has("BanMembers")) throw new Error("You do not have the *Ban Members* permission"); if (!member.permissions.has("BanMembers")) return "You do not have the *Ban Members* permission";
// Check if the user is below on the role list // Check if the user is below on the role list
if (!(memberPos > applyPos)) throw new Error("You do not have a role higher than that member"); if (!(memberPos > applyPos)) return "You do not have a role higher than that member";
// Allow ban // Allow ban
return true; return true;
}; };

@ -60,7 +60,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
`Are you sure you want to set the attachment log channel to <#${channel.id}>?` `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
) )
.setColor("Warning") .setColor("Warning")
.setFailedMessage("Attachment log channel not set", "Warning", "CHANNEL.TEXT.DELETE") .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true) .setInverted(true)
.send(true); .send(true);
if (confirmation.cancelled) return; if (confirmation.cancelled) return;

@ -56,7 +56,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
.setTitle("Log Channel") .setTitle("Log Channel")
.setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`) .setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
.setColor("Warning") .setColor("Warning")
.setFailedMessage("The log channel was not changed", "Danger", "CHANNEL.TEXT.DELETE") .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true) .setInverted(true)
.send(true); .send(true);
if (confirmation.cancelled) return; if (confirmation.cancelled) return;

@ -61,7 +61,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
`Are you sure you want to set the staff notifications channel to <#${channel.id}>?` `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
) )
.setColor("Warning") .setColor("Warning")
.setFailedMessage("Staff notifications channel not set", "Warning", "CHANNEL.TEXT.DELETE") .setFailedMessage("No changes were made", "Success", "CHANNEL.TEXT.CREATE")
.setInverted(true) .setInverted(true)
.send(true); .send(true);
if (confirmation.cancelled) return; if (confirmation.cancelled) return;

@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../utils/defaults.js"; import { LoadingEmbed } from "../../utils/defaults.js";
import Discord, { CommandInteraction, Message, ActionRowBuilder, GuildMember, StringSelectMenuBuilder, StringSelectMenuInteraction, AutocompleteInteraction } from "discord.js"; import Discord, { CommandInteraction, Message, ActionRowBuilder, GuildMember, StringSelectMenuBuilder, StringSelectMenuInteraction, SelectMenuOptionBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js"; import confirmationMessage from "../../utils/confirmationMessage.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@ -12,214 +12,34 @@ const command = (builder: SlashCommandSubcommandBuilder) =>
builder builder
.setName("stats") .setName("stats")
.setDescription("Controls channels which update when someone joins or leaves the server") .setDescription("Controls channels which update when someone joins or leaves the server")
.addChannelOption((option) => option.setName("channel").setDescription("The channel to modify"))
.addStringOption((option) =>
option
.setName("name")
.setDescription("The new channel name | Enter any text or use the extra variables like {memberCount}")
.setAutocomplete(true)
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => { // TODO: This command feels unintuitive. Clicking a channel in the select menu deletes it const callback = async (interaction: CommandInteraction) => {
// instead, it should give a submenu to edit the channel, enable/disable or delete it if (!interaction.guild) return;
singleNotify("statsChannelDeleted", interaction.guild!.id, true); let closed = false;
const m = (await interaction.reply({ let page = 0;
embeds: LoadingEmbed, do {
ephemeral: true, const config = await client.database.guilds.read(interaction.guild.id);
fetchReply: true const stats = config.stats; // stats: Record<string, { name: string; enabled: boolean }>
})) as Message; if (!stats) {
let config = await client.database.guilds.read(interaction.guild!.id); await interaction.editReply({embeds: [new EmojiEmbed()
if (interaction.options.get("name")?.value as string) { .setTitle("Stats channels")
let channel; .setDescription("You don't have ant stats channels yet")
if (Object.keys(config.stats).length >= 25) { .setStatus("Success")
return await interaction.editReply({ .setEmoji("")
embeds: [ ]})
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Stats Channel")
.setDescription("You can only have 25 stats channels in a server")
.setStatus("Danger")
]
});
} }
try { let pageSelect = new StringSelectMenuBuilder()
channel = interaction.options.get("channel")?.channel as Discord.Channel; .setCustomId("page")
} catch { .setPlaceholder("Select a stats channel to manage")
return await interaction.editReply({
embeds: [
new EmojiEmbed()
.setEmoji("CHANNEL.TEXT.DELETE")
.setTitle("Stats Channel")
.setDescription("The channel you provided is not a valid channel")
.setStatus("Danger")
]
});
}
channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild!.id) {
return interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription("You must choose a channel in this server")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
]
});
}
let newName = await convertCurlyBracketString(
interaction.options.get("name")?.value as string,
"",
"",
interaction.guild!.name,
interaction.guild!.members
);
if (interaction.options.get("channel")?.channel!.type === Discord.ChannelType.GuildText) {
newName = newName.toLowerCase().replace(/[\s]/g, "-");
}
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Stats Channel")
.setDescription(
`Are you sure you want to set <#${channel.id}> to a stats channel?\n\n*Preview: ${newName.replace(
/^ +| $/g,
""
)}*`
)
.setColor("Warning")
.setInverted(true)
.setFailedMessage(`Could not convert <#${channel.id}> to a stats chanel.`, "Danger", "CHANNEL.TEXT.DELETE")
.send(true);
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
const name = interaction.options.get("name")?.value as string;
const channel = interaction.options.get("channel")?.channel as Discord.TextChannel;
await client.database.guilds.write(interaction.guild!.id, {
[`stats.${channel.id}`]: { name: name, enabled: true }
});
const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
const data = {
meta: {
type: "statsChannelUpdate",
displayName: "Stats Channel Updated",
calculateType: "nucleusSettingsUpdated",
color: NucleusColors.yellow,
emoji: "CHANNEL.TEXT.EDIT",
timestamp: new Date().getTime()
},
list: {
memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
changedBy: entry(interaction.user.id, renderUser(interaction.user)),
channel: entry(channel.id, renderChannel(channel)),
name: entry(
interaction.options.get("name")?.value as string,
`\`${interaction.options.get("name")?.value as string}\``
)
},
hidden: {
guild: interaction.guild!.id
}
};
log(data);
} catch (e) {
console.log(e);
return interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription("Something went wrong and the stats channel could not be set")
.setStatus("Danger")
.setEmoji("CHANNEL.TEXT.DELETE")
],
components: []
});
}
} else {
return interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription("No changes were made")
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
],
components: []
});
}
await statsChannelAddCallback(client, interaction.member as GuildMember);
}
let timedOut = false;
while (!timedOut) {
config = await client.database.guilds.read(interaction.guild!.id);
const stats = config.stats;
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("remove")
.setMinValues(1) .setMinValues(1)
.setMaxValues(Math.max(1, Object.keys(stats).length)); .setMaxValues(1);
await interaction.editReply({ for (const [id, { name, enabled }] of Object.entries(stats)) {
embeds: [ pageSelect.addOption()
new EmojiEmbed()
.setTitle("Stats Channel")
.setDescription(
"The following channels update when someone joins or leaves the server. You can select a channel to remove it from the list."
)
.setStatus("Success")
.setEmoji("CHANNEL.TEXT.CREATE")
],
components: [
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
Object.keys(stats).length
? [
selectMenu
.setPlaceholder("Select a stats channel to remove, stopping it updating")
.addOptions(
Object.keys(stats).map((key) => ({
label: interaction.guild!.channels.cache.get(key)!.name,
value: key,
description: `${stats[key]!.name}`
}))
)
]
: [
selectMenu
.setPlaceholder("The server has no stats channels")
.setDisabled(true)
.setOptions([
{
label: "*Placeholder*",
value: "placeholder",
description: "No stats channels"
}
])
]
)
]
});
let i: StringSelectMenuInteraction;
try {
i = await m.awaitMessageComponent({
time: 300000,
filter: (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
}) as StringSelectMenuInteraction;
} catch (e) {
timedOut = true;
continue;
}
i.deferUpdate();
if (i.customId === "remove") {
const toRemove = i.values;
await client.database.guilds.write(
interaction.guild!.id,
null,
toRemove.map((k) => `stats.${k}`)
);
} }
} // [ Action... ] -> Edit, delete, reorder
await interaction.editReply({ // [Back][Next][Add]
embeds: [new Discord.EmbedBuilder(m.embeds[0]!.data).setFooter({ text: "Message timed out" })], } while (!closed);
components: [] closed = true;
});
}; };
const check = (interaction: CommandInteraction) => { const check = (interaction: CommandInteraction) => {
@ -229,21 +49,7 @@ const check = (interaction: CommandInteraction) => {
return true; return true;
}; };
const generateStatsChannelAutocomplete = (prompt: string): string[] => {
return [prompt];
};
const autocomplete = async (interaction: AutocompleteInteraction): Promise<string[]> => {
if (!interaction.guild) return [];
const prompt = interaction.options.getString("tag");
// generateStatsChannelAutocomplete(int.options.getString("name") ?? "")
const results = generateStatsChannelAutocomplete(prompt ?? "");
return results;
};
export { command }; export { command };
export { callback }; export { callback };
export { check }; export { check };
export { autocomplete };

@ -163,7 +163,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
"\nAre you sure you want to apply these settings?" "\nAre you sure you want to apply these settings?"
) )
.setColor("Warning") .setColor("Warning")
.setFailedMessage("Cancelled", "Warning", "GUILD.TICKET.CLOSE") // TODO: Set Actual Message .setFailedMessage("No changes were made", "Success", "GUILD.TICKET.OPEN")
.setInverted(true) .setInverted(true)
.send(true); .send(true);
if (confirmation.cancelled) return; if (confirmation.cancelled) return;

@ -103,7 +103,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
.setTitle("Welcome Events") .setTitle("Welcome Events")
.setDescription(generateKeyValueList(options)) .setDescription(generateKeyValueList(options))
.setColor("Warning") .setColor("Warning")
.setFailedMessage("Cancelled", "Warning", "GUILD.ROLES.DELETE") //TODO: Actual Message Needed .setFailedMessage("No changes were made", "Success", "GUILD.ROLES.CREATE")
.setInverted(true) .setInverted(true)
.send(true); .send(true);
if (confirmation.cancelled) return; if (confirmation.cancelled) return;
@ -324,7 +324,7 @@ const autocomplete = async (interaction: AutocompleteInteraction): Promise<strin
if (beforeLastOpenBracket !== null) { if (beforeLastOpenBracket !== null) {
if (afterLastOpenBracket !== null) { if (afterLastOpenBracket !== null) {
for (const replacement of validReplacements) { for (const replacement of validReplacements) {
if (replacement.startsWith(afterLastOpenBracket[0].slice(1))) { if (replacement.startsWith(afterLastOpenBracket[0]!.slice(1))) {
autocompletions.push(`${beforeLastOpenBracket[1]}{${replacement}}`); autocompletions.push(`${beforeLastOpenBracket[1]}{${replacement}}`);
} }
} }

@ -209,7 +209,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const check = async (interaction: CommandInteraction) => { const check = async (interaction: CommandInteraction) => {
const tracks = (await client.database.guilds.read(interaction.guild!.id)).tracks; const tracks = (await client.database.guilds.read(interaction.guild!.id)).tracks;
if (tracks.length === 0) throw new Error("This server does not have any tracks"); if (tracks.length === 0) return "This server does not have any tracks";
const member = interaction.member as GuildMember; const member = interaction.member as GuildMember;
// Allow the owner to promote anyone // Allow the owner to promote anyone
if (member.id === interaction.guild!.ownerId) return true; if (member.id === interaction.guild!.ownerId) return true;
@ -223,8 +223,7 @@ const check = async (interaction: CommandInteraction) => {
break; break;
} }
// Check if the user has manage_roles permission // Check if the user has manage_roles permission
if (!managed && !member.permissions.has("ManageRoles")) if (!managed && !member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
throw new Error("You do not have the *Manage Roles* permission");
// Allow track // Allow track
return true; return true;
}; };

@ -61,6 +61,13 @@ export default async function (walkthrough = false) {
out = false; out = false;
json = {}; json = {};
} }
if (json) {
if (json.token === defaultDict["token"] || json.developmentToken === defaultDict["developmentToken"]) {
console.log("\x1b[31m⚠ No main.json found, creating one.");
console.log(" \x1b[2mYou can edit src/config/main.json directly using template written to the file.\x1b[0m\n");
json = {};
}
}
for (const key in defaultDict) { for (const key in defaultDict) {
if (!json[key]) { if (!json[key]) {
if (walkthrough) { if (walkthrough) {

@ -15,7 +15,6 @@ export const event = "channelDelete";
export async function callback(client: NucleusClient, channel: GuildBasedChannel) { export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger; const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
// const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === channel.id).first();
const auditLog = (await getAuditLog(channel.guild, AuditLogEvent.ChannelDelete)) const auditLog = (await getAuditLog(channel.guild, AuditLogEvent.ChannelDelete))
.filter((entry: GuildAuditLogsEntry) => (entry.target as GuildBasedChannel)!.id === channel.id)[0]; .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildBasedChannel)!.id === channel.id)[0];
if (!auditLog) return; if (!auditLog) return;

@ -174,7 +174,7 @@ export async function callback(client: NucleusClient, oldChannel: GuildChannel,
if ((oldChannel as StageChannel).rtcRegion !== (newChannel as StageChannel).rtcRegion) if ((oldChannel as StageChannel).rtcRegion !== (newChannel as StageChannel).rtcRegion)
changes.region = entry( changes.region = entry(
[(oldChannel as StageChannel).rtcRegion ?? "Automatic", (newChannel as StageChannel).rtcRegion ?? "Automatic"], [(oldChannel as StageChannel).rtcRegion ?? "Automatic", (newChannel as StageChannel).rtcRegion ?? "Automatic"],
`${(oldChannel as StageChannel).rtcRegion?.toUpperCase() ?? "Automatic"} -> ${(newChannel as StageChannel).rtcRegion?.toUpperCase() ?? "Automatic"}` `${capitalize((oldChannel as StageChannel).rtcRegion?.toUpperCase() ?? "automatic")} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toUpperCase() ?? "automatic")}`
); );
break; break;
} }

@ -189,11 +189,10 @@ async function execute(check: Function | undefined, callback: Function | undefin
if (typeof result === "string") { if (typeof result === "string") {
const { NucleusColors } = client.logger const { NucleusColors } = client.logger
return data.reply({embeds: [new EmojiEmbed() return data.reply({embeds: [new EmojiEmbed()
.setTitle("")
.setDescription(result) .setDescription(result)
.setColor(NucleusColors.red) .setColor(NucleusColors.red)
.setEmoji(getEmojiByName("CONTROL.BLOCKCROSS")) .setEmoji(getEmojiByName("CONTROL.BLOCKCROSS"))
]}); ], ephemeral: true});
}; };
} }
callback(data); callback(data);

@ -13,13 +13,16 @@ class EmojiEmbed extends EmbedBuilder {
description = ""; description = "";
_generateTitle() { _generateTitle() {
if (this._emoji && !this._title) return getEmojiByName(this._emoji)
if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; } if (this._emoji) { return `${getEmojiByName(this._emoji)} ${this._title}`; }
return this._title; if (this._title) { return this._title };
return "";
} }
override setTitle(title: string) { override setTitle(title: string) {
this._title = title; this._title = title;
super.setTitle(this._generateTitle()); const proposedTitle = this._generateTitle();
if (proposedTitle) super.setTitle(proposedTitle);
return this; return this;
} }
override setDescription(description: string) { override setDescription(description: string) {
@ -29,7 +32,8 @@ class EmojiEmbed extends EmbedBuilder {
} }
setEmoji(emoji: string) { setEmoji(emoji: string) {
this._emoji = emoji; this._emoji = emoji;
super.setTitle(this._generateTitle()); const proposedTitle = this._generateTitle();
if (proposedTitle) super.setTitle(proposedTitle);
return this; return this;
} }
setStatus(color: "Danger" | "Warning" | "Success") { setStatus(color: "Danger" | "Warning" | "Success") {

Loading…
Cancel
Save