This commit is contained in:
Skillz4Killz
2022-08-28 11:19:13 +00:00
committed by GitHub
parent 9d6cc2f210
commit e064aa2aab
21 changed files with 67 additions and 58 deletions

View File

@@ -4,4 +4,3 @@ export * from "./editEmoji.ts";
export * from "./getEmoji.ts";
export * from "./getEmojis.ts";
export * from "./getEmojiUrl.ts";

View File

@@ -23,4 +23,3 @@ export * from "./getWidget.ts";
export * from "./getWidgetImageUrl.ts";
export * from "./getWidgetSettings.ts";
export * from "./leaveGuild.ts";

View File

@@ -3,7 +3,11 @@ import { ApplicationCommand } from "../../../transformers/applicationCommand.ts"
import { DiscordApplicationCommand } from "../../../types/discord.ts";
/** Fetches the global command for the given Id. If a guildId is provided, the guild command will be fetched. */
export async function getApplicationCommand(bot: Bot, commandId: bigint, options?: GetApplicationCommand): Promise<ApplicationCommand> {
export async function getApplicationCommand(
bot: Bot,
commandId: bigint,
options?: GetApplicationCommand,
): Promise<ApplicationCommand> {
const result = await bot.rest.runMethod<DiscordApplicationCommand>(
bot.rest,
"GET",

View File

@@ -6,7 +6,7 @@ import {
CreateApplicationCommand,
CreateContextApplicationCommand,
isContextApplicationCommand,
makeOptionsForCommand
makeOptionsForCommand,
} from "./createApplicationCommand.ts";
/**

View File

@@ -10,4 +10,3 @@ export * from "./kickMember.ts";
export * from "./pruneMembers.ts";
export * from "./searchMembers.ts";
export * from "./unbanMember.ts";

View File

@@ -7,7 +7,12 @@ import { AllowedMentions, FileContent, MessageComponents } from "../../types/dis
import { MessageComponentTypes } from "../../types/shared.ts";
/** Edit the message. */
export async function editMessage(bot: Bot, channelId: bigint, messageId: bigint, content: EditMessage): Promise<Message> {
export async function editMessage(
bot: Bot,
channelId: bigint,
messageId: bigint,
content: EditMessage,
): Promise<Message> {
const result = await bot.rest.runMethod<DiscordMessage>(
bot.rest,
"PATCH",

View File

@@ -13,4 +13,3 @@ export * from "./pinMessage.ts";
export * from "./publishMessage.ts";
export * from "./sendMessage.ts";
export * from "./unpinMessage.ts";

View File

@@ -6,7 +6,10 @@ import { DiscordUser } from "../../types/discord.ts";
* Modifies the bot's username or avatar.
* NOTE: username: if changed may cause the bot's discriminator to be randomized.
*/
export async function editBotProfile(bot: Bot, options: { username?: string; botAvatarURL?: string | null }): Promise<User> {
export async function editBotProfile(
bot: Bot,
options: { username?: string; botAvatarURL?: string | null },
): Promise<User> {
const avatar = options?.botAvatarURL ? await bot.utils.urlToBase64(options?.botAvatarURL) : options?.botAvatarURL;
const result = await bot.rest.runMethod<DiscordUser>(bot.rest, "PATCH", bot.constants.routes.USER_BOT(), {

View File

@@ -4,4 +4,3 @@ export * from "./editShardStatus.ts";
export * from "./getGatewayBot.ts";
export * from "./getNitroStickerPacks.ts";
export * from "./getUser.ts";

View File

@@ -1,7 +1,7 @@
import ping from "./ping";
export const COMMANDS = {
ping,
}
ping,
};
export default COMMANDS;
export default COMMANDS;

View File

@@ -4,9 +4,9 @@ import { processMessageCollectors } from "../../utils/collectors";
export function setMessageCreateEvent() {
bot.events.messageCreate = async function (_, message) {
processMessageCollectors(message);
await Promise.allSettled([
// SETUP-DD-TEMP: Add any functions you want to run on every message here. For example, automoderation filters.
]).catch(console.log)
// SETUP-DD-TEMP: Add any functions you want to run on every message here. For example, automoderation filters.
]).catch(console.log);
};
}

View File

@@ -1,9 +1,9 @@
import { setInteractionCreateEvent } from "./interactions/mod"
import { setMessageCreateEvent } from "./messages/create"
import { setRawEvent } from "./raw"
import { setInteractionCreateEvent } from "./interactions/mod";
import { setMessageCreateEvent } from "./messages/create";
import { setRawEvent } from "./raw";
export function setupEventHandlers() {
setInteractionCreateEvent()
setRawEvent()
setMessageCreateEvent()
}
setInteractionCreateEvent();
setRawEvent();
setMessageCreateEvent();
}

View File

@@ -1,28 +1,27 @@
const english = {
// Permissions
BUTTON_NOT_ALLOWED: '❌ You are not allowed to use this button.',
NEED_VIP: "❌ Only VIP users or servers can use this feature.",
// Execute Command
EXECUTE_COMMAND_NOT_FOUND: '❌ Something went wrong. I was not able to find this command.',
EXECUTE_COMMAND_ERROR: '❌ Something went wrong. The command execution has thrown an error.',
// Permissions
BUTTON_NOT_ALLOWED: "❌ You are not allowed to use this button.",
NEED_VIP: "❌ Only VIP users or servers can use this feature.",
// Language Command
LANGUAGE_NAME: 'language',
LANGUAGE_DESCRIPTION: '⚙️ Change the bots language.',
LANGUAGE_KEY_NAME: 'name',
LANGUAGE_KEY_DESCRIPTION: 'What language would you like to set?',
LANGUAGE_MISSING_KEY: '❌ No language was provided.',
LANGUAGE_INVALID_KEY: (languages: string[]) =>
`❌ I could not find a language with that name. Valid languages are: ${languages.join(' ')}`,
LANGUAGE_UPDATED: (language: string) => `The language has been updated to ${language}`,
// Ping Command
PING_NAME: 'ping',
PING_DESCRIPTION: '🏓 Check whether the bot is online and responsive.',
PING_RESPONSE: '🏓 Pong! I am online and responsive! :clock10:',
PING_RESPONSE_WITH_TIME: (time: number) => `🏓 Pong! ${time / 1000} seconds! I am online and responsive! :clock10:`,
} as const
export default english
// Execute Command
EXECUTE_COMMAND_NOT_FOUND: "❌ Something went wrong. I was not able to find this command.",
EXECUTE_COMMAND_ERROR: "❌ Something went wrong. The command execution has thrown an error.",
// Language Command
LANGUAGE_NAME: "language",
LANGUAGE_DESCRIPTION: "⚙️ Change the bots language.",
LANGUAGE_KEY_NAME: "name",
LANGUAGE_KEY_DESCRIPTION: "What language would you like to set?",
LANGUAGE_MISSING_KEY: "❌ No language was provided.",
LANGUAGE_INVALID_KEY: (languages: string[]) =>
`❌ I could not find a language with that name. Valid languages are: ${languages.join(" ")}`,
LANGUAGE_UPDATED: (language: string) => `The language has been updated to ${language}`,
// Ping Command
PING_NAME: "ping",
PING_DESCRIPTION: "🏓 Check whether the bot is online and responsive.",
PING_RESPONSE: "🏓 Pong! I am online and responsive! :clock10:",
PING_RESPONSE_WITH_TIME: (time: number) => `🏓 Pong! ${time / 1000} seconds! I am online and responsive! :clock10:`,
} as const;
export default english;

View File

@@ -17,4 +17,4 @@ const languages: Record<LanguageNames, Language> & Record<string, Language> = {
export default languages;
export type Language = Record<string, string | string[] | ((...args: any[]) => string)>;
export type LanguageNames = "english";
export type LanguageNames = "english";

View File

@@ -2,7 +2,7 @@
import { InteractionResponse, Message } from "discordeno";
declare module "discordeno" {
// We want to add something to the Interaction object.
// We want to add something to the Interaction object.
interface Interaction {
// Normally, to send a response you would have to do something like bot.helpers.sendInteractionResponse(interaction.id, interaction.token, { type: InteractionResponseTypes.ChannelMessageWithSource, data: { content: "text here" } })
// But with this reply method we added, it is as simple as interaction.reply("text here").

View File

@@ -27,7 +27,9 @@ export async function needMessage(memberId: bigint, channelId: bigint, options?:
export function collectMessages(options: CollectMessagesOptions): Promise<Message[]> {
return new Promise((resolve, reject) => {
bot.collectors.messages.get(options.key)?.reject("A new collector began before the user responded to the previous one.");
bot.collectors.messages.get(options.key)?.reject(
"A new collector began before the user responded to the previous one.",
);
bot.collectors.messages.set(options.key, {
...options,

View File

@@ -1,4 +1,4 @@
// SETUP-DD-TEMP: This file is an example, of how to customize an object properties that you do not want.
// SETUP-DD-TEMP: This file is an example, of how to customize an object properties that you do not want.
// Only keep the properties your bot uses. If your bot does not use emojis in cache, you can save all that memory.
// This file is currently disabled, but you can enable it should you choose when you go the customizer file.
// Feel free to delete this comment or file as you wish.

View File

@@ -26,4 +26,4 @@ export function customizeInteractionTransformer(bot: BotWithCustomProps) {
// Return the new customized object.
return interaction;
};
}
}

View File

@@ -29,7 +29,9 @@ export async function updateDevCommands(bot: Bot) {
return {
name: (translatedName || name).toLowerCase(),
description: translatedDescription || command!.description,
options: command.options ? createOptions(bot.transformers.snowflake(DEV_SERVER_ID), command.options, command.name) : undefined,
options: command.options
? createOptions(bot.transformers.snowflake(DEV_SERVER_ID), command.options, command.name)
: undefined,
};
}),
bot.transformers.snowflake(DEV_SERVER_ID),
@@ -39,7 +41,6 @@ export async function updateDevCommands(bot: Bot) {
// SETUP-DD-TEMP: You can make this able to be updated dynicamally by moving this value to something in the database and having a command to update it on the fly or as part of CI.
export const CURRENT_SLASH_COMMAND_VERSION = 1;
/** Whether the guild has the latest slash command version */
export async function usesLatestCommandVersion(guildId: bigint): Promise<boolean> {
return (await getCurrentCommandVersion(guildId)) === CURRENT_SLASH_COMMAND_VERSION;

View File

@@ -1,4 +1,4 @@
import { Intents, getBotIdFromToken } from "discordeno";
import { getBotIdFromToken, Intents } from "discordeno";
// General Configurations
/** Whether or not this process is a local development version. Change to false for the main production bot. */

View File

@@ -1,3 +1,3 @@
import { PrismaClient } from '@prisma/client'
import { PrismaClient } from "@prisma/client";
export const prisma = new PrismaClient()
export const prisma = new PrismaClient();