3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-12 04:55:01 +00:00

Update djs & knub (#395)

* update pkgs

Signed-off-by: GitHub <noreply@github.com>

* new knub typings

Signed-off-by: GitHub <noreply@github.com>

* more pkg updates

Signed-off-by: GitHub <noreply@github.com>

* more fixes

Signed-off-by: GitHub <noreply@github.com>

* channel typings

Signed-off-by: GitHub <noreply@github.com>

* more message utils typings fixes

Signed-off-by: GitHub <noreply@github.com>

* migrate permissions

Signed-off-by: GitHub <noreply@github.com>

* fix: InternalPoster webhookables

Signed-off-by: GitHub <noreply@github.com>

* djs typings: Attachment & Util

Signed-off-by: GitHub <noreply@github.com>

* more typings

Signed-off-by: GitHub <noreply@github.com>

* fix: rename permissionNames

Signed-off-by: GitHub <noreply@github.com>

* more fixes

Signed-off-by: GitHub <noreply@github.com>

* half the number of errors

* knub commands => messageCommands

Signed-off-by: GitHub <noreply@github.com>

* configPreprocessor => configParser

Signed-off-by: GitHub <noreply@github.com>

* fix channel.messages

Signed-off-by: GitHub <noreply@github.com>

* revert automod any typing

Signed-off-by: GitHub <noreply@github.com>

* more configParser typings

Signed-off-by: GitHub <noreply@github.com>

* revert

Signed-off-by: GitHub <noreply@github.com>

* remove knub type params

Signed-off-by: GitHub <noreply@github.com>

* fix more MessageEmbed / MessageOptions

Signed-off-by: GitHub <noreply@github.com>

* dumb commit for @almeidx to see why this is stupid

Signed-off-by: GitHub <noreply@github.com>

* temp disable custom_events

Signed-off-by: GitHub <noreply@github.com>

* more minor typings fixes - 23 err left

Signed-off-by: GitHub <noreply@github.com>

* update djs dep

* +debug build method (revert this)

Signed-off-by: GitHub <noreply@github.com>

* Revert "+debug build method (revert this)"

This reverts commit a80af1e729.

* Redo +debug build (Revert this)

Signed-off-by: GitHub <noreply@github.com>

* uniform before/after Load shorthands

Signed-off-by: GitHub <noreply@github.com>

* remove unused imports & add prettier plugin

Signed-off-by: GitHub <noreply@github.com>

* env fixes for web platform hosting

Signed-off-by: GitHub <noreply@github.com>

* feat: knub v32-next; related fixes

* fix: allow legacy keys in change_perms action

* fix: request Message Content intent

* fix: use Knub's config validation logic in API

* fix(dashboard): fix error when there are no message and/or slash commands in a plugin

* fix(automod): start_thread action thread options

* fix(CustomEvents): message command types

* chore: remove unneeded type annotation

* feat: add forum channel icon; use thread icon for news threads

* chore: make tslint happy

* chore: fix formatting

---------

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: almeidx <almeidx@pm.me>
Co-authored-by: Dragory <2606411+Dragory@users.noreply.github.com>
This commit is contained in:
Tiago R 2023-04-01 12:58:17 +01:00 committed by GitHub
parent 293115af22
commit 06877e90cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
476 changed files with 2965 additions and 3251 deletions

View file

@ -1,13 +1,14 @@
import { PluginOptions } from "knub";
import { onGuildEvent } from "../../data/GuildEvents";
import { GuildReminders } from "../../data/GuildReminders";
import { makeIoTsConfigParser } from "../../pluginUtils";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { RemindCmd } from "./commands/RemindCmd";
import { RemindersCmd } from "./commands/RemindersCmd";
import { RemindersDeleteCmd } from "./commands/RemindersDeleteCmd";
import { ConfigSchema, RemindersPluginType } from "./types";
import { onGuildEvent } from "../../data/GuildEvents";
import { postReminder } from "./functions/postReminder";
import { ConfigSchema, RemindersPluginType } from "./types";
const defaultOptions: PluginOptions<RemindersPluginType> = {
config: {
@ -28,14 +29,15 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
showInDocs: true,
info: {
prettyName: "Reminders",
configSchema: ConfigSchema,
},
dependencies: () => [TimeAndDatePlugin],
configSchema: ConfigSchema,
configParser: makeIoTsConfigParser(ConfigSchema),
defaultOptions,
// prettier-ignore
commands: [
messageCommands: [
RemindCmd,
RemindersCmd,
RemindersDeleteCmd,
@ -50,13 +52,17 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
},
afterLoad(pluginData) {
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "reminder", (reminder) =>
const { state, guild } = pluginData;
state.unregisterGuildEventListener = onGuildEvent(guild.id, "reminder", (reminder) =>
postReminder(pluginData, reminder),
);
},
beforeUnload(pluginData) {
pluginData.state.unregisterGuildEventListener?.();
pluginData.state.unloaded = true;
const { state } = pluginData;
state.unregisterGuildEventListener?.();
state.unloaded = true;
},
});

View file

@ -1,11 +1,11 @@
import humanizeDuration from "humanize-duration";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { convertDelayStringToMS, messageLink } from "../../../utils";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { remindersCmd } from "../types";
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop";
export const RemindCmd = remindersCmd({
trigger: ["remind", "remindme", "reminder"],

View file

@ -1,8 +1,8 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { clearUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { sorter } from "../../../utils";
import { remindersCmd } from "../types";
import { clearUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop";
export const RemindersDeleteCmd = remindersCmd({
trigger: ["reminders delete", "reminders d"],

View file

@ -1,15 +1,14 @@
import { HTTPError, Snowflake } from "discord.js";
import { GuildPluginData } from "knub";
import { RemindersPluginType } from "../types";
import { Reminder } from "../../../data/entities/Reminder";
import { DiscordAPIError, HTTPError, Snowflake, TextChannel } from "discord.js";
import { disableLinkPreviews } from "knub/helpers";
import moment from "moment-timezone";
import { disableLinkPreviews } from "knub/dist/helpers";
import { DBDateFormat, isDiscordHTTPError, SECONDS } from "../../../utils";
import humanizeDuration from "humanize-duration";
import { Reminder } from "../../../data/entities/Reminder";
import { DBDateFormat } from "../../../utils";
import { RemindersPluginType } from "../types";
export async function postReminder(pluginData: GuildPluginData<RemindersPluginType>, reminder: Reminder) {
const channel = pluginData.guild.channels.cache.get(reminder.channel_id as Snowflake);
if (channel && (channel.isText() || channel.isThread())) {
if (channel && (channel.isTextBased() || channel.isThread())) {
try {
// Only show created at date if one exists
if (moment.utc(reminder.created_at).isValid()) {
@ -34,7 +33,7 @@ export async function postReminder(pluginData: GuildPluginData<RemindersPluginTy
// tslint:disable-next-line:no-console
console.warn(`Error when posting reminder for ${reminder.user_id} in guild ${reminder.guild_id}: ${String(err)}`);
if (err instanceof HTTPError && err.code >= 500) {
if (err instanceof HTTPError && err.status >= 500) {
// If we get a server error, try again later
return;
}

View file

@ -1,5 +1,5 @@
import * as t from "io-ts";
import { BasePluginType, typedGuildCommand } from "knub";
import { BasePluginType, guildPluginMessageCommand } from "knub";
import { GuildReminders } from "../../data/GuildReminders";
export const ConfigSchema = t.type({
@ -20,4 +20,4 @@ export interface RemindersPluginType extends BasePluginType {
};
}
export const remindersCmd = typedGuildCommand<RemindersPluginType>();
export const remindersCmd = guildPluginMessageCommand<RemindersPluginType>();