3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 21:35:02 +00:00

Merge branch '240811_application_commands_merge_2' into next

This commit is contained in:
Dragory 2024-08-11 22:28:41 +03:00
commit 43b8017985
No known key found for this signature in database
279 changed files with 6192 additions and 3044 deletions

View file

@ -1,6 +1,7 @@
import { PluginOptions, guildPlugin } from "knub";
import { onGuildEvent } from "../../data/GuildEvents.js";
import { GuildReminders } from "../../data/GuildReminders.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin.js";
import { RemindCmd } from "./commands/RemindCmd.js";
import { RemindersCmd } from "./commands/RemindersCmd.js";
@ -44,6 +45,10 @@ export const RemindersPlugin = guildPlugin<RemindersPluginType>()({
state.unloaded = false;
},
beforeStart(pluginData) {
pluginData.state.common = pluginData.getPlugin(CommonPlugin);
},
afterLoad(pluginData) {
const { state, guild } = pluginData;

View file

@ -2,7 +2,6 @@ import humanizeDuration from "humanize-duration";
import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { convertDelayStringToMS, messageLink } from "../../../utils.js";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
import { remindersCmd } from "../types.js";
@ -38,7 +37,7 @@ export const RemindCmd = remindersCmd({
// "Delay string" i.e. e.g. "2h30m"
const ms = convertDelayStringToMS(args.time);
if (ms === null) {
sendErrorMessage(pluginData, msg.channel, "Invalid reminder time");
void pluginData.state.common.sendErrorMessage(msg, "Invalid reminder time");
return;
}
@ -46,7 +45,7 @@ export const RemindCmd = remindersCmd({
}
if (!reminderTime.isValid() || reminderTime.isBefore(now)) {
sendErrorMessage(pluginData, msg.channel, "Invalid reminder time");
void pluginData.state.common.sendErrorMessage(msg, "Invalid reminder time");
return;
}
@ -67,9 +66,8 @@ export const RemindCmd = remindersCmd({
pluginData.getPlugin(TimeAndDatePlugin).getDateFormat("pretty_datetime"),
);
sendSuccessMessage(
pluginData,
msg.channel,
void pluginData.state.common.sendSuccessMessage(
msg,
`I will remind you in **${timeUntilReminder}** at **${prettyReminderTime}**`,
);
},

View file

@ -1,6 +1,5 @@
import humanizeDuration from "humanize-duration";
import moment from "moment-timezone";
import { sendErrorMessage } from "../../../pluginUtils.js";
import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils.js";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
import { remindersCmd } from "../types.js";
@ -12,7 +11,7 @@ export const RemindersCmd = remindersCmd({
async run({ message: msg, pluginData }) {
const reminders = await pluginData.state.reminders.getRemindersByUserId(msg.author.id);
if (reminders.length === 0) {
sendErrorMessage(pluginData, msg.channel, "No reminders");
void pluginData.state.common.sendErrorMessage(msg, "No reminders");
return;
}

View file

@ -1,6 +1,5 @@
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
import { clearUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils.js";
import { sorter } from "../../../utils.js";
import { remindersCmd } from "../types.js";
@ -17,7 +16,7 @@ export const RemindersDeleteCmd = remindersCmd({
reminders.sort(sorter("remind_at"));
if (args.num > reminders.length || args.num <= 0) {
sendErrorMessage(pluginData, msg.channel, "Unknown reminder");
void pluginData.state.common.sendErrorMessage(msg, "Unknown reminder");
return;
}
@ -25,6 +24,6 @@ export const RemindersDeleteCmd = remindersCmd({
clearUpcomingReminder(toDelete);
await pluginData.state.reminders.delete(toDelete.id);
sendSuccessMessage(pluginData, msg.channel, "Reminder deleted");
void pluginData.state.common.sendSuccessMessage(msg, "Reminder deleted");
},
});

View file

@ -1,6 +1,7 @@
import { BasePluginType, guildPluginMessageCommand } from "knub";
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
import z from "zod";
import { GuildReminders } from "../../data/GuildReminders.js";
import { CommonPlugin } from "../Common/CommonPlugin.js";
export const zRemindersConfig = z.strictObject({
can_use: z.boolean(),
@ -12,6 +13,7 @@ export interface RemindersPluginType extends BasePluginType {
state: {
reminders: GuildReminders;
tries: Map<number, number>;
common: pluginUtils.PluginPublicInterface<typeof CommonPlugin>;
unregisterGuildEventListener: () => void;