3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +00:00

Merge branch 'master' of github.com:ZeppelinBot/Zeppelin into feat/application-commands

This commit is contained in:
Lily Bergonzat 2024-02-16 14:26:34 +01:00
commit 2c0e4b37ca
235 changed files with 3464 additions and 4799 deletions

View file

@ -2,10 +2,9 @@ import { PluginOptions } from "knub";
import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
import { makeIoTsConfigParser } from "../../pluginUtils";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { NamesCmd } from "./commands/NamesCmd";
import { ConfigSchema, NameHistoryPluginType } from "./types";
import { NameHistoryPluginType, zNameHistoryConfig } from "./types";
const defaultOptions: PluginOptions<NameHistoryPluginType> = {
config: {
@ -25,7 +24,7 @@ export const NameHistoryPlugin = zeppelinGuildPlugin<NameHistoryPluginType>()({
name: "name_history",
showInDocs: false,
configParser: makeIoTsConfigParser(ConfigSchema),
configParser: (input) => zNameHistoryConfig.parse(input),
defaultOptions,
// prettier-ignore

View file

@ -4,7 +4,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { MAX_NICKNAME_ENTRIES_PER_USER } from "../../../data/GuildNicknameHistory";
import { MAX_USERNAME_ENTRIES_PER_USER } from "../../../data/UsernameHistory";
import { NICKNAME_RETENTION_PERIOD } from "../../../data/cleanup/nicknames";
import { DAYS, renderUserUsername } from "../../../utils";
import { DAYS, renderUsername } from "../../../utils";
import { CommonPlugin } from "../../Common/CommonPlugin";
import { nameHistoryCmd } from "../types";
@ -31,7 +31,7 @@ export const NamesCmd = nameHistoryCmd({
const usernameRows = usernames.map((r) => `\`[${r.timestamp}]\` **${disableCodeBlocks(r.username)}**`);
const user = await pluginData.client.users.fetch(args.userId as Snowflake).catch(() => null);
const currentUsername = user ? renderUserUsername(user) : args.userId;
const currentUsername = user ? renderUsername(user) : args.userId;
const nicknameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);
const usernameDays = Math.round(NICKNAME_RETENTION_PERIOD / DAYS);

View file

@ -1,16 +1,15 @@
import * as t from "io-ts";
import { BasePluginType, guildPluginEventListener, guildPluginMessageCommand } from "knub";
import z from "zod";
import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory";
export const ConfigSchema = t.type({
can_view: t.boolean,
export const zNameHistoryConfig = z.strictObject({
can_view: z.boolean(),
});
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
export interface NameHistoryPluginType extends BasePluginType {
config: TConfigSchema;
config: z.infer<typeof zNameHistoryConfig>;
state: {
nicknameHistory: GuildNicknameHistory;
usernameHistory: UsernameHistory;