mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
CompanionChannels: snake_case for config options, 'companions' -> 'entries'
This commit is contained in:
parent
6eff4dd80f
commit
fb481aa583
1 changed files with 8 additions and 8 deletions
|
@ -6,15 +6,15 @@ import { tNullable } from "../utils";
|
||||||
|
|
||||||
// Permissions using these numbers: https://abal.moe/Eris/docs/reference (add all allowed/denied ones up)
|
// Permissions using these numbers: https://abal.moe/Eris/docs/reference (add all allowed/denied ones up)
|
||||||
const CompanionChannelOpts = t.type({
|
const CompanionChannelOpts = t.type({
|
||||||
voiceChannelIds: t.array(t.string),
|
voice_channel_ids: t.array(t.string),
|
||||||
textChannelIds: t.array(t.string),
|
text_channel_ids: t.array(t.string),
|
||||||
permissions: t.number,
|
permissions: t.number,
|
||||||
enabled: tNullable(t.boolean),
|
enabled: tNullable(t.boolean),
|
||||||
});
|
});
|
||||||
type TCompanionChannelOpts = t.TypeOf<typeof CompanionChannelOpts>;
|
type TCompanionChannelOpts = t.TypeOf<typeof CompanionChannelOpts>;
|
||||||
|
|
||||||
const ConfigSchema = t.type({
|
const ConfigSchema = t.type({
|
||||||
companions: t.record(t.string, CompanionChannelOpts),
|
entries: t.record(t.string, CompanionChannelOpts),
|
||||||
});
|
});
|
||||||
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export class CompanionChannelPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
protected static getStaticDefaultOptions(): IPluginOptions<TConfigSchema> {
|
protected static getStaticDefaultOptions(): IPluginOptions<TConfigSchema> {
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
companions: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ export class CompanionChannelPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
*/
|
*/
|
||||||
protected getCompanionChannelOptsForVoiceChannelId(userId, voiceChannelId): TCompanionChannelOpts[] {
|
protected getCompanionChannelOptsForVoiceChannelId(userId, voiceChannelId): TCompanionChannelOpts[] {
|
||||||
const config = this.getConfigForMemberIdAndChannelId(userId, voiceChannelId);
|
const config = this.getConfigForMemberIdAndChannelId(userId, voiceChannelId);
|
||||||
return Object.values(config.companions)
|
return Object.values(config.entries)
|
||||||
.filter(opts => opts.voiceChannelIds.includes(voiceChannelId))
|
.filter(opts => opts.voice_channel_ids.includes(voiceChannelId))
|
||||||
.map(opts => Object.assign({}, defaultCompanionChannelOpts, opts));
|
.map(opts => Object.assign({}, defaultCompanionChannelOpts, opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ export class CompanionChannelPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
for (const oldChannelOpts of oldChannelOptsArr) {
|
for (const oldChannelOpts of oldChannelOptsArr) {
|
||||||
for (const channelId of oldChannelOpts.textChannelIds) {
|
for (const channelId of oldChannelOpts.text_channel_ids) {
|
||||||
oldPerms.set(channelId, oldChannelOpts.permissions);
|
oldPerms.set(channelId, oldChannelOpts.permissions);
|
||||||
permsToDelete.add(channelId);
|
permsToDelete.add(channelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const newChannelOpts of newChannelOptsArr) {
|
for (const newChannelOpts of newChannelOptsArr) {
|
||||||
for (const channelId of newChannelOpts.textChannelIds) {
|
for (const channelId of newChannelOpts.text_channel_ids) {
|
||||||
if (oldPerms.get(channelId) !== newChannelOpts.permissions) {
|
if (oldPerms.get(channelId) !== newChannelOpts.permissions) {
|
||||||
// Update text channel perms if the channel we transitioned from didn't already have the same text channel perms
|
// Update text channel perms if the channel we transitioned from didn't already have the same text channel perms
|
||||||
permsToSet.set(channelId, newChannelOpts.permissions);
|
permsToSet.set(channelId, newChannelOpts.permissions);
|
||||||
|
|
Loading…
Add table
Reference in a new issue