Skip to content

Commit f545cf6

Browse files
author
xyzjesper
committed
Added isInDevelopment Function for Dev Modules. Added export commad for Guild and Users. Fixed Embed Editor
1 parent 57b40b8 commit f545cf6

File tree

11 files changed

+126
-28
lines changed

11 files changed

+126
-28
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MONGODBURL=your-url-to-database
22
CONFIG_PATH=/mnt/server/config.yml or /bot/config.yml
33
TWITCH_TOKEN_URL=only-for-scripts-folder
4+
ENVIRONMENT="PRODUCTION"
45

56
# Disabled
67
SENTRY_AUTH_TOKEN=

src/helper/utilityHelper.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import {
22
AnySelectMenuInteraction,
3-
ButtonInteraction,
3+
ButtonInteraction, ChatInputCommandInteraction, Message, MessageFlags,
44
ModalSubmitInteraction
55
} from "discord.js";
66
import {createCanvas} from "canvas";
77
import FormData from "form-data";
88
import {Config} from "../main/config.js";
99
import axios from "axios";
10+
import * as process from "node:process";
11+
import {ExtendedClient} from "../types/client.js";
12+
import {convertToEmojiPng} from "./emojis.js";
13+
import fs from "fs";
14+
import path from "path";
1015

1116
export function getInteractionData(interaction: ButtonInteraction | ModalSubmitInteraction | AnySelectMenuInteraction, split: number) {
1217
return interaction.customId.split(":")[split];
@@ -90,4 +95,24 @@ export async function createPollImage(poll: { title: any; description: any; opti
9095
}
9196
const data = await req.data;
9297
return data.files[0].url ?? null;
93-
}
98+
}
99+
100+
export async function isInDevelopment(
101+
client: ExtendedClient,
102+
interaction: ButtonInteraction | ChatInputCommandInteraction | ModalSubmitInteraction | AnySelectMenuInteraction,
103+
message?: string,
104+
emoji?: string,
105+
) {
106+
// Default
107+
emoji = await convertToEmojiPng("barrier", client.user.id)
108+
message = "Failed to handle this feature, it is in Development!"
109+
110+
if (process.env.ENVIRONMENT == "DEV") {
111+
112+
} else {
113+
return await interaction.reply({
114+
flags: MessageFlags.Ephemeral,
115+
content: `## ${emoji} ${message}`,
116+
})
117+
}
118+
}

src/main/startup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import colors from "colors";
44
import {ShardingManager} from "discord.js";
55
import {Logger} from "./logger.js";
66
import {Config, configStartup} from "./config.js"
7+
import * as process from "node:process";
78

89
colors.enable();
910

1011
await configStartup();
1112

13+
Logger.info(`Running on ${process.env.ENVIRONMENT} Environment.`.cyan)
14+
1215
Sentry.init({
1316
dsn: process.env.SENTRY_DSN,
1417
sendDefaultPii: true,

src/modules/embed/modals/modal-embed-create-author-img.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export default {
3434
const oldAuthor = embeds[embedIndex].data.author;
3535

3636
embeds[embedIndex].setAuthor({
37-
name: oldAuthor.name ?? "",
37+
name: oldAuthor?.name ?? "",
3838
iconURL: imageUrl,
39-
url: oldAuthor.url ?? undefined,
39+
url: oldAuthor?.url ?? undefined,
4040
});
4141

4242
if (message.webhookId) {

src/modules/embed/modals/modal-embed-create-author-url.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default {
3333
const oldAuthor = embeds[embedIndex].data.author
3434

3535
embeds[embedIndex].setAuthor({
36-
name: oldAuthor.name ?? "",
37-
iconURL: oldAuthor.icon_url ?? undefined,
36+
name: oldAuthor?.name ?? "",
37+
iconURL: oldAuthor?.icon_url ?? undefined,
3838
url: link
3939
});
4040

src/modules/embed/modals/modal-embed-create-author.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export default {
2626
const oldAuthor = embeds[embedIndex].data.author;
2727
embeds[embedIndex].setAuthor({
2828
name: author,
29-
iconURL: oldAuthor.icon_url ?? undefined,
30-
url: oldAuthor.url ?? undefined,
29+
iconURL: oldAuthor?.icon_url ?? undefined,
30+
url: oldAuthor?.url ?? undefined,
3131
});
3232

3333
if (message.webhookId) {

src/modules/embed/modals/modal-embed-create-footer-img.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
const oldFooter = embeds[embedIndex].data.footer
3636

3737
embeds[embedIndex].setFooter({
38-
text: oldFooter.text ?? '',
38+
text: oldFooter?.text ?? '',
3939
iconURL: imgURL
4040
});
4141

src/modules/embed/modals/modal-embed-create-footer.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Client, EmbedBuilder, MessageFlags, ModalSubmitInteraction } from "discord.js";
2-
import { ExtendedClient } from "../../../types/client.js";
1+
import {Client, EmbedBuilder, MessageFlags, ModalSubmitInteraction} from "discord.js";
2+
import {ExtendedClient} from "../../../types/client.js";
33

44
export default {
55
id: "modal-embed-create-footer",
@@ -9,7 +9,7 @@ export default {
99
"embed-create-options-footer-input"
1010
);
1111

12-
const [, messageId, embedIndexStr] = interaction.customId.split(":");
12+
const [_, messageId, embedIndexStr] = interaction.customId.split(":");
1313
const embedIndex = Number(embedIndexStr ?? "0");
1414

1515
const message = await interaction.channel.messages.fetch(messageId);
@@ -23,10 +23,13 @@ export default {
2323
}
2424

2525
const oldFooter = embeds[embedIndex].data.footer
26-
26+
2727
embeds[embedIndex].setFooter({
2828
text: text,
29-
iconURL: oldFooter.icon_url ?? null
29+
});
30+
if (oldFooter?.icon_url) embeds[embedIndex].setFooter({
31+
text: text,
32+
iconURL: oldFooter?.icon_url ?? undefined
3033
});
3134

3235
if (message.webhookId) {
@@ -41,10 +44,10 @@ export default {
4144
}
4245

4346
await interaction.deferUpdate();
44-
return await webhook.editMessage(message.id, { embeds });
47+
return await webhook.editMessage(message.id, {embeds});
4548
}
4649

4750
await interaction.deferUpdate();
48-
await message.edit({ embeds });
51+
await message.edit({embeds});
4952
}
5053
};

src/modules/moderation/buttons/moderation-automod-disbot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {ActionRowBuilder, ButtonInteraction, ModalBuilder, TextInputBuilder, TextInputStyle,} from "discord.js";
22
import {ExtendedClient} from "../../../types/client.js";
3+
import {isInDevelopment} from "../../../helper/utilityHelper.js";
34

45
export default {
56
id: "moderation-automod-disbot",
@@ -9,8 +10,9 @@ export default {
910
* @param {ExtendedClient} client
1011
*/
1112
async execute(interaction: ButtonInteraction, client: ExtendedClient) {
13+
await isInDevelopment(client, interaction)
1214

1315
// Select your GuildDisBotAutoModeration!
14-
16+
1517
},
1618
};

src/modules/moderation/commands/subCommand/moderation.scout.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {ExtendedClient} from "../../../../types/client.js";
99
import {convertToEmojiPng} from "../../../../helper/emojis.js";
1010
import {PermissionType} from "../../../../enums/permissionType.js";
1111
import {database} from "../../../../main/database.js";
12+
import {isInDevelopment} from "../../../../helper/utilityHelper.js";
1213

1314
export default {
1415
subCommand: "moderation.scout",
@@ -28,13 +29,6 @@ export default {
2829
interaction: ChatInputCommandInteraction,
2930
client: ExtendedClient
3031
) {
31-
32-
await interaction.reply({
33-
flags: MessageFlags.Ephemeral | MessageFlags.IsComponentsV2,
34-
components: [
35-
new ContainerBuilder().addTextDisplayComponents(new TextDisplayBuilder().setContent(`## ${await convertToEmojiPng("info", client.user.id)} This Feature is currently in development!\n -# Normally I don't do this but for this system it would be too annoying to do it differently, I ask for your understanding`))
36-
37-
]
38-
})
32+
await isInDevelopment(client, interaction)
3933
},
4034
};

0 commit comments

Comments
 (0)