Update to Knub30.0.0-beta.37 and Eris 0.15, first pass
This commit is contained in:
parent
84da543205
commit
f6be4f4af6
133 changed files with 6507 additions and 380 deletions
|
@ -13,7 +13,8 @@ const defaultOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()("companion_channels", {
|
||||
export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPluginType>()({
|
||||
name: "companion_channels",
|
||||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Companion channels",
|
||||
|
@ -30,7 +31,7 @@ export const CompanionChannelsPlugin = zeppelinGuildPlugin<CompanionChannelsPlug
|
|||
|
||||
events: [VoiceChannelJoinEvt, VoiceChannelSwitchEvt, VoiceChannelLeaveEvt],
|
||||
|
||||
onLoad(pluginData) {
|
||||
afterLoad(pluginData) {
|
||||
pluginData.state.errorCooldownManager = new CooldownManager();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,9 +2,9 @@ import { companionChannelsEvt } from "../types";
|
|||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
import { stripObjectToScalars } from "../../../utils";
|
||||
|
||||
export const VoiceChannelJoinEvt = companionChannelsEvt(
|
||||
"voiceChannelJoin",
|
||||
({ pluginData, args: { member, newChannel } }) => {
|
||||
export const VoiceChannelJoinEvt = companionChannelsEvt({
|
||||
event: "voiceChannelJoin",
|
||||
listener({ pluginData, args: { member, newChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelLeaveEvt = companionChannelsEvt(
|
||||
"voiceChannelLeave",
|
||||
({ pluginData, args: { member, oldChannel } }) => {
|
||||
export const VoiceChannelLeaveEvt = companionChannelsEvt({
|
||||
event: "voiceChannelLeave",
|
||||
listener({ pluginData, args: { member, oldChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, null, oldChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { companionChannelsEvt } from "../types";
|
||||
import { handleCompanionPermissions } from "../functions/handleCompanionPermissions";
|
||||
|
||||
export const VoiceChannelSwitchEvt = companionChannelsEvt(
|
||||
"voiceChannelSwitch",
|
||||
({ pluginData, args: { member, oldChannel, newChannel } }) => {
|
||||
export const VoiceChannelSwitchEvt = companionChannelsEvt({
|
||||
event: "voiceChannelSwitch",
|
||||
listener({ pluginData, args: { member, oldChannel, newChannel } }) {
|
||||
handleCompanionPermissions(pluginData, member.id, newChannel, oldChannel);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6,12 +6,12 @@ const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
|
|||
enabled: true,
|
||||
};
|
||||
|
||||
export function getCompanionChannelOptsForVoiceChannelId(
|
||||
export async function getCompanionChannelOptsForVoiceChannelId(
|
||||
pluginData: GuildPluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannel: VoiceChannel,
|
||||
): TCompanionChannelOpts[] {
|
||||
const config = pluginData.config.getMatchingConfig({ userId, channelId: voiceChannel.id });
|
||||
): Promise<TCompanionChannelOpts[]> {
|
||||
const config = await pluginData.config.getMatchingConfig({ userId, channelId: voiceChannel.id });
|
||||
return Object.values(config.entries)
|
||||
.filter(
|
||||
opts =>
|
||||
|
|
|
@ -36,10 +36,10 @@ export async function handleCompanionPermissions(
|
|||
const permsToSet: Map<string, number> = new Map(); // channelId => permissions
|
||||
|
||||
const oldChannelOptsArr: TCompanionChannelOpts[] = oldChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannel)
|
||||
? await getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannel)
|
||||
: [];
|
||||
const newChannelOptsArr: TCompanionChannelOpts[] = voiceChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannel)
|
||||
? await getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannel)
|
||||
: [];
|
||||
|
||||
for (const oldChannelOpts of oldChannelOptsArr) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { tNullable } from "../../utils";
|
||||
import { BasePluginType, CooldownManager, guildEventListener } from "knub";
|
||||
import { BasePluginType, CooldownManager, typedGuildEventListener } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
||||
|
@ -29,4 +29,4 @@ export interface CompanionChannelsPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const companionChannelsEvt = guildEventListener<CompanionChannelsPluginType>();
|
||||
export const companionChannelsEvt = typedGuildEventListener<CompanionChannelsPluginType>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue