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,4 +1,4 @@
|
|||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { CompanionChannelsPluginType, ConfigSchema, TCompanionChannelOpts } from "./types";
|
||||
import { VoiceChannelJoinEvt } from "./events/VoiceChannelJoinEvt";
|
||||
import { VoiceChannelSwitchEvt } from "./events/VoiceChannelSwitchEvt";
|
||||
|
@ -13,7 +13,7 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const CompanionChannelsPlugin = zeppelinPlugin<CompanionChannelsPluginType>()("companion_channels", {
|
||||
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()("companion_channels", {
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Companion channels",
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { eventListener } from "knub";
|
||||
import { CompanionChannelsPluginType } from "../types";
|
||||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
import { stripObjectToScalars } from "src/utils";
|
||||
import { stripObjectToScalars } from "../../../utils";
|
||||
|
||||
export const VoiceChannelJoinEvt = eventListener<CompanionChannelsPluginType>()(
|
||||
export const VoiceChannelJoinEvt = companionChannelsEvt(
|
||||
"voiceChannelJoin",
|
||||
({ pluginData, args: { member, newChannel } }) => {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { eventListener } from "knub";
|
||||
import { CompanionChannelsPluginType } from "../types";
|
||||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelLeaveEvt = eventListener<CompanionChannelsPluginType>()(
|
||||
export const VoiceChannelLeaveEvt = companionChannelsEvt(
|
||||
"voiceChannelLeave",
|
||||
({ pluginData, args: { member, oldChannel } }) => {
|
||||
handleCompanionPermissions(pluginData, member.id, null, oldChannel);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { eventListener } from "knub";
|
||||
import { CompanionChannelsPluginType } from "../types";
|
||||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelSwitchEvt = eventListener<CompanionChannelsPluginType>()(
|
||||
export const VoiceChannelSwitchEvt = companionChannelsEvt(
|
||||
"voiceChannelSwitch",
|
||||
({ pluginData, args: { member, oldChannel, newChannel } }) => {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VoiceChannel } from "eris";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
||||
|
||||
const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
||||
|
@ -7,7 +7,7 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
|||
};
|
||||
|
||||
export function getCompanionChannelOptsForVoiceChannelId(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel: VoiceChannel,
|
||||
): TCompanionChannelOpts[] {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
||||
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
|
||||
import { PluginData } from "knub";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { TextChannel, VoiceChannel } from "eris";
|
||||
import { isDiscordRESTError, MINUTES } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
@ -10,19 +10,19 @@ const ERROR_COOLDOWN_KEY = "errorCooldown";
|
|||
const ERROR_COOLDOWN = 5 * MINUTES;
|
||||
|
||||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel: VoiceChannel,
|
||||
oldChannel?: VoiceChannel,
|
||||
);
|
||||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel: null,
|
||||
oldChannel: VoiceChannel,
|
||||
);
|
||||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel?: VoiceChannel,
|
||||
oldChannel?: VoiceChannel,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../utils";
|
||||
import { BasePluginType, CooldownManager } from "knub";
|
||||
import { BasePluginType, CooldownManager, guildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
||||
|
@ -28,3 +28,5 @@ export interface CompanionChannelsPluginType extends BasePluginType {
|
|||
errorCooldownManager: CooldownManager;
|
||||
};
|
||||
}
|
||||
|
||||
export const companionChannelsEvt = guildEventListener<CompanionChannelsPluginType>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue