Development (#47)

pull/67/head
Skyler 3 years ago committed by GitHub
commit 3535e78302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -127,7 +127,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
); );
} }
for (const option of options) { for (const option of options) {
optionString += `> ${option.name} (${ApplicationCommandOptionType[option.type]})- ${ optionString += `> \`${option.name}\` (${ApplicationCommandOptionType[option.type]}) - ${
option.description option.description
}\n`; }\n`;
} }

@ -79,7 +79,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
if (!("awaitMessageComponent" in channel)) return; if (!("awaitMessageComponent" in channel)) return;
try { try {
i1 = await channel!.awaitMessageComponent<ComponentType.Button>({ i1 = await channel!.awaitMessageComponent<ComponentType.Button>({
filter: (i) => i.customId === "admin" && i.user.id === interaction.user.id, filter: (i) => i.customId === "admin" && i.user.id === interaction.user.id && i.message.id === m.id,
time: 300000 time: 300000
}); });
} catch (e) { } catch (e) {
@ -120,7 +120,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
let i; let i;
try { try {
i = await m.awaitMessageComponent<ComponentType.Button>({ i = await m.awaitMessageComponent<ComponentType.Button>({
filter: (i) => i.user.id === interaction.user.id, filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id,
time: 300000 time: 300000
}); });
} catch { } catch {

@ -67,7 +67,11 @@ export const callback = async (interaction: CommandInteraction): Promise<void> =
}; };
do { do {
const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents( const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().setCustomId("edit").setLabel("Edit Embed").setStyle(ButtonStyle.Secondary), new ButtonBuilder()
.setCustomId("edit")
.setLabel("Edit Embed")
.setStyle(ButtonStyle.Secondary)
.setEmoji(getEmojiByName("ICONS.EDIT") as APIMessageComponentEmoji),
new ButtonBuilder() new ButtonBuilder()
.setCustomId("send") .setCustomId("send")
.setLabel("Send") .setLabel("Send")
@ -143,7 +147,8 @@ export const callback = async (interaction: CommandInteraction): Promise<void> =
let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction | Discord.StringSelectMenuInteraction; let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction | Discord.StringSelectMenuInteraction;
try { try {
i = (await interaction.channel!.awaitMessageComponent({ i = (await interaction.channel!.awaitMessageComponent({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id, filter: (i: Discord.Interaction) =>
i.user.id === interaction.user.id && i.isMessageComponent() && i.message.id === m.id,
time: 300000 time: 300000
})) as })) as
| Discord.ButtonInteraction | Discord.ButtonInteraction
@ -223,17 +228,18 @@ export const callback = async (interaction: CommandInteraction): Promise<void> =
case "send": { case "send": {
await i.deferUpdate(); await i.deferUpdate();
const channel = interaction.guild!.channels.cache.get(data.channel!) as Discord.TextChannel; const channel = interaction.guild!.channels.cache.get(data.channel!) as Discord.TextChannel;
const components = new ActionRowBuilder<ButtonBuilder>(); const messageData: MessageCreateOptions = {};
for (const button of data.buttons) { for (const button of data.buttons) {
components.addComponents( messageData.components = [
new ButtonBuilder() new ActionRowBuilder<ButtonBuilder>().addComponents(
.setCustomId(button) new ButtonBuilder()
.setLabel(buttonNames[button]!) .setCustomId(button)
.setStyle(ButtonStyle.Primary) .setLabel(buttonNames[button]!)
); .setStyle(ButtonStyle.Primary)
)
];
} }
const messageData: MessageCreateOptions = { components: [components] }; if (data.title || data.description || data.color) {
if (data.title || data.description) {
const e = new EmojiEmbed(); const e = new EmojiEmbed();
if (data.title) e.setTitle(data.title); if (data.title) e.setTitle(data.title);
if (data.description) e.setDescription(data.description); if (data.description) e.setDescription(data.description);

@ -20,7 +20,7 @@ export const command = new SlashCommandSubcommandBuilder()
.setDescription("Automatically publish messages posted in announcement channels"); .setDescription("Automatically publish messages posted in announcement channels");
export const callback = async (interaction: CommandInteraction): Promise<void> => { export const callback = async (interaction: CommandInteraction): Promise<void> => {
await interaction.reply({ const m = await interaction.reply({
embeds: LoadingEmbed, embeds: LoadingEmbed,
ephemeral: true, ephemeral: true,
fetchReply: true fetchReply: true
@ -70,7 +70,8 @@ export const callback = async (interaction: CommandInteraction): Promise<void> =
let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction; let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
try { try {
i = (await interaction.channel!.awaitMessageComponent({ i = (await interaction.channel!.awaitMessageComponent({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id, filter: (i: Discord.Interaction) =>
i.user.id === interaction.user.id && i.isMessageComponent() && i.message.id === m.id,
time: 300000 time: 300000
})) as Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction; })) as Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
} catch (e) { } catch (e) {

@ -18,7 +18,7 @@ const command = (builder: SlashCommandSubcommandBuilder) =>
const callback = async (interaction: CommandInteraction): Promise<unknown> => { const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (interaction.guild) client.database.premium.hasPremium(interaction.guild.id).finally(() => {}); if (interaction.guild) client.database.premium.hasPremium(interaction.guild.id).finally(() => {});
await interaction.reply({ const m = await interaction.reply({
embeds: LoadingEmbed, embeds: LoadingEmbed,
ephemeral: true, ephemeral: true,
fetchReply: true fetchReply: true
@ -79,7 +79,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
let i: Discord.ButtonInteraction | Discord.SelectMenuInteraction; let i: Discord.ButtonInteraction | Discord.SelectMenuInteraction;
try { try {
i = (await interaction.channel!.awaitMessageComponent({ i = (await m.awaitMessageComponent({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id, filter: (i: Discord.Interaction) => i.user.id === interaction.user.id,
time: 300000 time: 300000
})) as Discord.ButtonInteraction | Discord.SelectMenuInteraction; })) as Discord.ButtonInteraction | Discord.SelectMenuInteraction;

@ -122,7 +122,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
let i: ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction; let i: ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction;
try { try {
i = (await m.awaitMessageComponent({ i = (await m.awaitMessageComponent({
filter: (i) => i.user.id === interaction.user.id, filter: (i) => i.user.id === interaction.user.id && i.isMessageComponent() && i.message.id === m.id,
time: 300000 time: 300000
})) as ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction; })) as ButtonInteraction | StringSelectMenuInteraction | ChannelSelectMenuInteraction;
} catch (e) { } catch (e) {

@ -19,7 +19,7 @@ const command = (builder: SlashCommandSubcommandBuilder) =>
const callback = async (interaction: CommandInteraction): Promise<unknown> => { const callback = async (interaction: CommandInteraction): Promise<unknown> => {
if (!interaction.guild) return; if (!interaction.guild) return;
await interaction.reply({ const m = await interaction.reply({
embeds: LoadingEmbed, embeds: LoadingEmbed,
ephemeral: true, ephemeral: true,
fetchReply: true fetchReply: true
@ -67,7 +67,8 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction; let i: Discord.ButtonInteraction | Discord.ChannelSelectMenuInteraction;
try { try {
i = await interaction.channel!.awaitMessageComponent<ComponentType.Button | ComponentType.ChannelSelect>({ i = await interaction.channel!.awaitMessageComponent<ComponentType.Button | ComponentType.ChannelSelect>({
filter: (i: Discord.Interaction) => i.user.id === interaction.user.id, filter: (i: Discord.Interaction) =>
i.user.id === interaction.user.id && i.isMessageComponent() && i.message.id === m.id,
time: 300000 time: 300000
}); });
} catch (e) { } catch (e) {

@ -1,7 +1,7 @@
import fs from "fs"; import fs from "fs";
import * as readLine from "node:readline/promises"; import * as readLine from "node:readline/promises";
const defaultDict: Record<string, string | string[] | boolean | Record<string, string>> = { const defaultDict: Record<string, string | string[] | boolean | Record<string, string | number>> = {
developmentToken: "Your development bot token (Used for testing in one server, rather than production)", developmentToken: "Your development bot token (Used for testing in one server, rather than production)",
developmentGuildID: "Your development guild ID", developmentGuildID: "Your development guild ID",
enableDevelopment: true, enableDevelopment: true,
@ -29,7 +29,12 @@ const defaultDict: Record<string, string | string[] | boolean | Record<string, s
pastebinApiKey: "An API key for pastebin (optional)", pastebinApiKey: "An API key for pastebin (optional)",
pastebinUsername: "Your pastebin username (optional)", pastebinUsername: "Your pastebin username (optional)",
pastebinPassword: "Your pastebin password (optional)", pastebinPassword: "Your pastebin password (optional)",
rapidApiKey: "Your RapidAPI key (optional), used for Unscan" rapidApiKey: "Your RapidAPI key (optional), used for Unscan",
clamav: {
socket: "Your ClamAV socket file (optional)",
host: "Your ClamAV host (optional)",
port: "Your ClamAV port (optional)"
}
}; };
const readline = readLine.createInterface({ const readline = readLine.createInterface({

@ -19,7 +19,11 @@ declare const config: {
}; };
baseUrl: string; baseUrl: string;
rapidApiKey: string; rapidApiKey: string;
clamavSocket: string; clamav: {
socket?: string;
host?: string;
port?: number;
};
}; };
export default config; export default config;

@ -26,7 +26,9 @@ interface MalwareSchema {
const nsfw_model = await nsfwjs.load("file://dist/reflex/nsfwjs/example/nsfw_demo/public/model/", { size: 299 }); const nsfw_model = await nsfwjs.load("file://dist/reflex/nsfwjs/example/nsfw_demo/public/model/", { size: 299 });
const clamscanner = await new ClamScan().init({ const clamscanner = await new ClamScan().init({
clamdscan: { clamdscan: {
socket: config.clamavSocket socket: "socket" in config.clamav ? (config.clamav.socket as string) : false,
host: "host" in config.clamav ? (config.clamav.host as string) : false,
port: "port" in config.clamav ? (config.clamav.port as number) : false
} }
}); });

Loading…
Cancel
Save