Update to new Knub 30 beta. Code clean-up.
This commit is contained in:
parent
5d579446c5
commit
2f470dc37a
299 changed files with 1075 additions and 1004 deletions
|
@ -1,7 +1,7 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { ConfigSchema, RemindersPluginType } from "./types";
|
||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { GuildReminders } from "src/data/GuildReminders";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { GuildReminders } from "../../data/GuildReminders";
|
||||
import { postDueRemindersLoop } from "./utils/postDueRemindersLoop";
|
||||
import { RemindCmd } from "./commands/RemindCmd";
|
||||
import { RemindersCmd } from "./commands/RemindersCmd";
|
||||
|
@ -22,7 +22,7 @@ const defaultOptions: PluginOptions<RemindersPluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const RemindersPlugin = zeppelinPlugin<RemindersPluginType>()("reminders", {
|
||||
export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()("reminders", {
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Reminders",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import moment from "moment-timezone";
|
||||
import { convertDelayStringToMS, messageLink } from "src/utils";
|
||||
import { convertDelayStringToMS, messageLink } from "../../../utils";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { remindersCommand } from "../types";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { remindersCmd } from "../types";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
|
||||
export const RemindCmd = remindersCommand({
|
||||
export const RemindCmd = remindersCmd({
|
||||
trigger: ["remind", "remindme"],
|
||||
usage: "!remind 3h Remind me of this in 3 hours please",
|
||||
permission: "can_use",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { remindersCommand } from "../types";
|
||||
import { sendErrorMessage } from "src/pluginUtils";
|
||||
import { createChunkedMessage, DBDateFormat, sorter } from "src/utils";
|
||||
import { remindersCmd } from "../types";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils";
|
||||
import moment from "moment-timezone";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
|
||||
export const RemindersCmd = remindersCommand({
|
||||
export const RemindersCmd = remindersCmd({
|
||||
trigger: "reminders",
|
||||
permission: "can_use",
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { remindersCommand } from "../types";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { sorter } from "src/utils";
|
||||
import { remindersCmd } from "../types";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { sorter } from "../../../utils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const RemindersDeleteCmd = remindersCommand({
|
||||
export const RemindersDeleteCmd = remindersCmd({
|
||||
trigger: ["reminders delete", "reminders d"],
|
||||
permission: "can_use",
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, command } from "knub";
|
||||
import { GuildReminders } from "src/data/GuildReminders";
|
||||
import { BasePluginType, guildCommand } from "knub";
|
||||
import { GuildReminders } from "../../data/GuildReminders";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
can_use: t.boolean,
|
||||
|
@ -19,4 +19,4 @@ export interface RemindersPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const remindersCommand = command<RemindersPluginType>();
|
||||
export const remindersCmd = guildCommand<RemindersPluginType>();
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { TextChannel } from "eris";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { RemindersPluginType } from "../types";
|
||||
import moment from "moment-timezone";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { disableLinkPreviews } from "knub/dist/helpers";
|
||||
import { SECONDS } from "src/utils";
|
||||
import { SECONDS } from "../../../utils";
|
||||
|
||||
const REMINDER_LOOP_TIME = 10 * SECONDS;
|
||||
const MAX_TRIES = 3;
|
||||
|
||||
export async function postDueRemindersLoop(pluginData: PluginData<RemindersPluginType>) {
|
||||
export async function postDueRemindersLoop(pluginData: GuildPluginData<RemindersPluginType>) {
|
||||
const pendingReminders = await pluginData.state.reminders.getDueReminders();
|
||||
for (const reminder of pendingReminders) {
|
||||
const channel = pluginData.guild.channels.get(reminder.channel_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue