mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Allow companion_channels to take category ID
This commit is contained in:
parent
205f7721ea
commit
ff053d2f05
5 changed files with 24 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
|||
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
|
||||
import { getCompanionChannelOptsForVoiceChannelId } from "./getCompanionChannelOptsForVoiceChannelId";
|
||||
import { PluginData } from "knub";
|
||||
import { TextChannel } from "eris";
|
||||
import { TextChannel, VoiceChannel } from "eris";
|
||||
import { isDiscordRESTError, MINUTES } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
@ -12,20 +12,20 @@ const ERROR_COOLDOWN = 5 * MINUTES;
|
|||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannelId: string,
|
||||
oldChannelId?: string,
|
||||
voiceChannel: VoiceChannel,
|
||||
oldChannel?: VoiceChannel,
|
||||
);
|
||||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannelId: null,
|
||||
oldChannelId: string,
|
||||
voiceChannel: null,
|
||||
oldChannel: VoiceChannel,
|
||||
);
|
||||
export async function handleCompanionPermissions(
|
||||
pluginData: PluginData<CompanionChannelsPluginType>,
|
||||
userId: string,
|
||||
voiceChannelId?: string,
|
||||
oldChannelId?: string,
|
||||
voiceChannel?: VoiceChannel,
|
||||
oldChannel?: VoiceChannel,
|
||||
) {
|
||||
if (pluginData.state.errorCooldownManager.isOnCooldown(ERROR_COOLDOWN_KEY)) {
|
||||
return;
|
||||
|
@ -35,11 +35,11 @@ export async function handleCompanionPermissions(
|
|||
const oldPerms: Map<string, number> = new Map(); // channelId => permissions
|
||||
const permsToSet: Map<string, number> = new Map(); // channelId => permissions
|
||||
|
||||
const oldChannelOptsArr: TCompanionChannelOpts[] = oldChannelId
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannelId)
|
||||
const oldChannelOptsArr: TCompanionChannelOpts[] = oldChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, oldChannel)
|
||||
: [];
|
||||
const newChannelOptsArr: TCompanionChannelOpts[] = voiceChannelId
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannelId)
|
||||
const newChannelOptsArr: TCompanionChannelOpts[] = voiceChannel
|
||||
? getCompanionChannelOptsForVoiceChannelId(pluginData, userId, voiceChannel)
|
||||
: [];
|
||||
|
||||
for (const oldChannelOpts of oldChannelOptsArr) {
|
||||
|
@ -65,7 +65,7 @@ export async function handleCompanionPermissions(
|
|||
for (const channelId of permsToDelete) {
|
||||
const channel = pluginData.guild.channels.get(channelId);
|
||||
if (!channel || !(channel instanceof TextChannel)) continue;
|
||||
await channel.deletePermission(userId, `Companion Channel for ${oldChannelId} | User Left`);
|
||||
await channel.deletePermission(userId, `Companion Channel for ${oldChannel.id} | User Left`);
|
||||
}
|
||||
|
||||
for (const [channelId, permissions] of permsToSet) {
|
||||
|
@ -76,7 +76,7 @@ export async function handleCompanionPermissions(
|
|||
permissions,
|
||||
0,
|
||||
"member",
|
||||
`Companion Channel for ${voiceChannelId} | User Joined`,
|
||||
`Companion Channel for ${voiceChannel.id} | User Joined`,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue