pull/63/head
TheCodedProf 3 years ago
parent 27a0511ef9
commit 528de570df

@ -93,7 +93,10 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary), new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary),
new ButtonBuilder().setCustomId("announce").setLabel("Announce to all Guilds").setStyle(ButtonStyle.Danger) new ButtonBuilder()
.setCustomId("announce")
.setLabel("Announce to all Guilds")
.setStyle(ButtonStyle.Danger)
) )
] ]
}); });
@ -148,7 +151,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
GuildID = out.fields.getTextInputValue("guildID"); GuildID = out.fields.getTextInputValue("guildID");
} else if (!client.guilds.cache.has(GuildID)) { } else if (!client.guilds.cache.has(GuildID)) {
await interaction.editReply({ await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")], embeds: [
new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")
],
components: [] components: []
}); });
} }
@ -158,10 +163,19 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().setCustomId("stats").setLabel("Stats").setStyle(ButtonStyle.Primary), new ButtonBuilder().setCustomId("stats").setLabel("Stats").setStyle(ButtonStyle.Primary),
new ButtonBuilder().setCustomId("data").setLabel("Guild data").setStyle(ButtonStyle.Secondary), new ButtonBuilder()
new ButtonBuilder().setCustomId("cache").setLabel("Reset cache").setStyle(ButtonStyle.Success), .setCustomId("data")
.setLabel("Guild data")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("cache")
.setLabel("Reset cache")
.setStyle(ButtonStyle.Success),
new ButtonBuilder().setCustomId("leave").setLabel("Leave").setStyle(ButtonStyle.Danger), new ButtonBuilder().setCustomId("leave").setLabel("Leave").setStyle(ButtonStyle.Danger),
new ButtonBuilder().setCustomId("purge").setLabel("Delete data").setStyle(ButtonStyle.Danger) new ButtonBuilder()
.setCustomId("purge")
.setLabel("Delete data")
.setStyle(ButtonStyle.Danger)
) )
] ]
}); });
@ -178,7 +192,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!guild) { if (!guild) {
await i.deferUpdate(); await i.deferUpdate();
await interaction.editReply({ await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")], embeds: [
new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")
],
components: [] components: []
}); });
return; return;
@ -230,7 +246,10 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
const attachment = new AttachmentBuilder(buffer).setName("data.json"); const attachment = new AttachmentBuilder(buffer).setName("data.json");
await interaction.editReply({ await interaction.editReply({
embeds: [ embeds: [
new EmojiEmbed().setTitle("Data").setDescription(`Data for ${guild.name}`).setStatus("Success") new EmojiEmbed()
.setTitle("Data")
.setDescription(`Data for ${guild.name}`)
.setStatus("Success")
], ],
components: [], components: [],
files: [attachment] files: [attachment]
@ -274,7 +293,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
break; break;
} }
case "announce": { case "announce": {
const channelsToNotify = await client.database.guilds.staffChannels() const channelsToNotify = await client.database.guilds.staffChannels();
const modal2 = new ModalBuilder() const modal2 = new ModalBuilder()
.addComponents( .addComponents(
new ActionRowBuilder<TextInputBuilder>().addComponents( new ActionRowBuilder<TextInputBuilder>().addComponents(
@ -303,13 +322,18 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()
.setTitle("Announcement") .setTitle("Announcement")
.setDescription(`Announcement will be sent to ${channelsToNotify.length} channels.\n\n${announcement}`) .setDescription(
`Announcement will be sent to ${channelsToNotify.length} channels.\n\n${announcement}`
)
.setStatus("Success") .setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN") .setEmoji("SETTINGS.STATS.GREEN")
], ],
components: [ components: [
new ActionRowBuilder<ButtonBuilder>().addComponents( new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().setCustomId("confirm").setLabel("Confirm").setStyle(ButtonStyle.Success), new ButtonBuilder()
.setCustomId("confirm")
.setLabel("Confirm")
.setStyle(ButtonStyle.Success),
new ButtonBuilder().setCustomId("cancel").setLabel("Cancel").setStyle(ButtonStyle.Danger) new ButtonBuilder().setCustomId("cancel").setLabel("Cancel").setStyle(ButtonStyle.Danger)
) )
] ]
@ -330,7 +354,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()
.setTitle("Announcement") .setTitle("Announcement")
.setDescription(`Sending to ${channelsToNotify.length} channels. Preview:\n\n${announcement}`) .setDescription(
`Sending to ${channelsToNotify.length} channels. Preview:\n\n${announcement}`
)
.setStatus("Success") .setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN") .setEmoji("SETTINGS.STATS.GREEN")
], ],
@ -341,9 +367,12 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
.setDescription(announcement) .setDescription(announcement)
.setStatus("Danger") .setStatus("Danger")
.setEmoji("NUCLEUS.LOGO") .setEmoji("NUCLEUS.LOGO")
.setFooter({text: `Sent by ${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL()}) .setFooter({
text: `Sent by ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL()
});
for (const channel of channelsToNotify) { for (const channel of channelsToNotify) {
const ch = await client.channels.fetch(channel) as GuildTextBasedChannel | null; const ch = (await client.channels.fetch(channel)) as GuildTextBasedChannel | null;
if (!ch) continue; if (!ch) continue;
await ch.send({ await ch.send({
embeds: [announcementEmbed] embeds: [announcementEmbed]
@ -353,12 +382,14 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()
.setTitle("Announcement") .setTitle("Announcement")
.setDescription(`Sent to ${channelsToNotify.length} channels. Preview:\n\n${announcement}`) .setDescription(
`Sent to ${channelsToNotify.length} channels. Preview:\n\n${announcement}`
)
.setStatus("Success") .setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN") .setEmoji("SETTINGS.STATS.GREEN")
], ],
components: [] components: []
}) });
} else if (i.customId === "cancel") { } else if (i.customId === "cancel") {
await i.deferUpdate(); await i.deferUpdate();
await interaction.editReply({ await interaction.editReply({

@ -144,8 +144,13 @@ export class Guilds {
} }
async staffChannels(): Promise<string[]> { async staffChannels(): Promise<string[]> {
const entries = await this.guilds.find({ "logging.staff.channel": {$exists: true}}, { projection: { "logging.staff.channel": 1, _id: 0 } }).toArray(); const entries = await this.guilds
return entries.map(e => e.logging.staff.channel!); .find(
{ "logging.staff.channel": { $exists: true } },
{ projection: { "logging.staff.channel": 1, _id: 0 } }
)
.toArray();
return entries.map((e) => e.logging.staff.channel!);
} }
} }

@ -1,4 +1,4 @@
import emojis from "../config/emojis.js" import emojis from "../config/emojis.js";
import _ from "lodash"; import _ from "lodash";
interface EmojisIndex { interface EmojisIndex {
@ -18,8 +18,7 @@ function getEmojiPaths(obj: EmojisIndex, path: string[] = []) {
} }
getEmojiPaths(emojis); getEmojiPaths(emojis);
function getEmojiByName(name: (typeof EMOJIPATHS)[number], format?: string): string {
function getEmojiByName(name: typeof EMOJIPATHS[number], format?: string): string {
const parts = name.split("."); const parts = name.split(".");
let id: string | EmojisIndex | EmojisIndex[] | undefined = emojis; let id: string | EmojisIndex | EmojisIndex[] | undefined = emojis;
for (const part of parts) { for (const part of parts) {

Loading…
Cancel
Save