mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
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,10 +1,10 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { PluginOptions } from "knub";
|
||||
import { ConfigSchema, SlowmodePluginType } from "./types";
|
||||
import { GuildSlowmodes } from "src/data/GuildSlowmodes";
|
||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
||||
import { GuildLogs } from "src/data/GuildLogs";
|
||||
import { SECONDS } from "src/utils";
|
||||
import { GuildSlowmodes } from "../../data/GuildSlowmodes";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { SECONDS } from "../../utils";
|
||||
import { onMessageCreate } from "./util/onMessageCreate";
|
||||
import { clearExpiredSlowmodes } from "./util/clearExpiredSlowmodes";
|
||||
import { SlowmodeDisableCmd } from "./commands/SlowmodeDisableCmd";
|
||||
|
@ -35,7 +35,7 @@ const defaultOptions: PluginOptions<SlowmodePluginType> = {
|
|||
],
|
||||
};
|
||||
|
||||
export const SlowmodePlugin = zeppelinPlugin<SlowmodePluginType>()("slowmode", {
|
||||
export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()("slowmode", {
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Slowmode",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { slowmodeCmd } from "../types";
|
||||
import { clearBotSlowmodeFromUserId } from "../util/clearBotSlowmodeFromUserId";
|
||||
import { asSingleLine, disableInlineCode } from "../../../utils";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { slowmodeCmd } from "../types";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
import { createChunkedMessage } from "knub/dist/helpers";
|
||||
import { errorMessage } from "src/utils";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
|
||||
export const SlowmodeListCmd = slowmodeCmd({
|
||||
|
|
|
@ -2,8 +2,8 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|||
import { slowmodeCmd } from "../types";
|
||||
import { TextChannel } from "eris";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { asSingleLine, DAYS, disableInlineCode, HOURS, MINUTES } from "src/utils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { asSingleLine, DAYS, disableInlineCode, HOURS, MINUTES } from "../../../utils";
|
||||
import { disableBotSlowmodeForChannel } from "../util/disableBotSlowmodeForChannel";
|
||||
import { actualDisableSlowmodeCmd } from "../util/actualDisableSlowmodeCmd";
|
||||
import { getMissingPermissions } from "../../../utils/getMissingPermissions";
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, command, eventListener } from "knub";
|
||||
import { GuildSlowmodes } from "src/data/GuildSlowmodes";
|
||||
import { GuildSavedMessages } from "src/data/GuildSavedMessages";
|
||||
import { GuildLogs } from "src/data/GuildLogs";
|
||||
import { BasePluginType, guildCommand, guildEventListener } from "knub";
|
||||
import { GuildSlowmodes } from "../../data/GuildSlowmodes";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
use_native_slowmode: t.boolean,
|
||||
|
@ -24,5 +24,5 @@ export interface SlowmodePluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const slowmodeCmd = command<SlowmodePluginType>();
|
||||
export const slowmodeEvt = eventListener<SlowmodePluginType>();
|
||||
export const slowmodeCmd = guildCommand<SlowmodePluginType>();
|
||||
export const slowmodeEvt = guildEventListener<SlowmodePluginType>();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Message } from "eris";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { disableBotSlowmodeForChannel } from "./disableBotSlowmodeForChannel";
|
||||
import { noop } from "src/utils";
|
||||
import { noop } from "../../../utils";
|
||||
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
|
||||
import { BOT_SLOWMODE_DISABLE_PERMISSIONS } from "../requiredPermissions";
|
||||
import { missingPermissionError } from "../../../utils/missingPermissionError";
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { SlowmodePluginType } from "../types";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { Constants, GuildChannel, TextChannel } from "eris";
|
||||
import { isDiscordRESTError, stripObjectToScalars, UnknownUser } from "src/utils";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { logger } from "src/logger";
|
||||
import { isDiscordRESTError, stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
|
||||
export async function applyBotSlowmodeToUserId(
|
||||
pluginData: PluginData<SlowmodePluginType>,
|
||||
pluginData: GuildPluginData<SlowmodePluginType>,
|
||||
channel: GuildChannel & TextChannel,
|
||||
userId: string,
|
||||
) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
|
||||
export async function clearBotSlowmodeFromUserId(
|
||||
pluginData: PluginData<SlowmodePluginType>,
|
||||
pluginData: GuildPluginData<SlowmodePluginType>,
|
||||
channel: GuildChannel & TextChannel,
|
||||
userId: string,
|
||||
force = false,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { LogType } from "src/data/LogType";
|
||||
import { logger } from "src/logger";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { logger } from "../../../logger";
|
||||
import { GuildChannel, TextChannel } from "eris";
|
||||
import { stripObjectToScalars, UnknownUser } from "src/utils";
|
||||
import { stripObjectToScalars, UnknownUser } from "../../../utils";
|
||||
import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
|
||||
|
||||
export async function clearExpiredSlowmodes(pluginData: PluginData<SlowmodePluginType>) {
|
||||
export async function clearExpiredSlowmodes(pluginData: GuildPluginData<SlowmodePluginType>) {
|
||||
const expiredSlowmodeUsers = await pluginData.state.slowmodes.getExpiredSlowmodeUsers();
|
||||
for (const user of expiredSlowmodeUsers) {
|
||||
const channel = pluginData.guild.channels.get(user.channel_id);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { GuildChannel, TextChannel } from "eris";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { clearBotSlowmodeFromUserId } from "./clearBotSlowmodeFromUserId";
|
||||
|
||||
export async function disableBotSlowmodeForChannel(
|
||||
pluginData: PluginData<SlowmodePluginType>,
|
||||
pluginData: GuildPluginData<SlowmodePluginType>,
|
||||
channel: GuildChannel & TextChannel,
|
||||
) {
|
||||
// Disable channel slowmode
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { SavedMessage } from "src/data/entities/SavedMessage";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage";
|
||||
import { TextChannel } from "eris";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SlowmodePluginType } from "../types";
|
||||
import { resolveMember } from "src/utils";
|
||||
import { resolveMember } from "../../../utils";
|
||||
import { applyBotSlowmodeToUserId } from "./applyBotSlowmodeToUserId";
|
||||
import { hasPermission } from "src/pluginUtils";
|
||||
import { hasPermission } from "../../../pluginUtils";
|
||||
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
|
||||
import { BOT_SLOWMODE_PERMISSIONS } from "../requiredPermissions";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { missingPermissionError } from "../../../utils/missingPermissionError";
|
||||
|
||||
export async function onMessageCreate(pluginData: PluginData<SlowmodePluginType>, msg: SavedMessage) {
|
||||
export async function onMessageCreate(pluginData: GuildPluginData<SlowmodePluginType>, msg: SavedMessage) {
|
||||
if (msg.is_bot) return;
|
||||
|
||||
const channel = pluginData.guild.channels.get(msg.channel_id) as TextChannel;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue