Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
change the filter for zac cause it's annoying me and he won't fix the…
Browse files Browse the repository at this point in the history
… nickname he added for chrome
  • Loading branch information
sebasptsch committed Oct 25, 2022
1 parent b9b6778 commit e6d8ff9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
24 changes: 17 additions & 7 deletions src/classes/Secondary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,28 @@ export default class DynamicaSecondary {
emoji,
locked,
});

const oldName = discordChannel.name;
if (discordChannel.name !== name) {
if (!discordChannel.manageable) {
throw new Error('Channel not manageable');
try {
await discordChannel.edit({
name,
});
} catch (error) {
if (error instanceof DiscordAPIError) {
if (error.code === 50013) {
await this.delete();
} else if (error.code === 10003) {
await this.delete(false, true);
} else {
this.logger.error(error);
}
}
}
await discordChannel.edit({
name,
});

this.logger
.scope('Secondary', this.id)
.debug(
`Secondary channel ${discordChannel.name} in ${discordChannel.guild.name} name changed.`
`Secondary channel in ${discordChannel.guild.name} name changed from ${oldName} to ${name}.`
);
}
} catch (error) {
Expand Down
25 changes: 22 additions & 3 deletions src/events/VoiceStateUpdateEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import Primaries from '@/classes/Primaries';
import Secondaries from '@/classes/Secondaries';
import updatePresence from '@/utils/presence';
import Event, { EventToken } from '@/classes/Event';
import { VoiceState } from 'discord.js';
import { DiscordAPIError, VoiceState } from 'discord.js';
import { Service } from 'typedi';
import Logger from '@/services/Logger';

@Service({ id: EventToken, multiple: true })
export default class VoiceStateUpdateEvent extends Event<'voiceStateUpdate'> {
constructor(private secondaries: Secondaries, private primaries: Primaries) {
constructor(
private secondaries: Secondaries,
private primaries: Primaries,
private logger: Logger
) {
super();
}

Expand Down Expand Up @@ -35,7 +40,21 @@ export default class VoiceStateUpdateEvent extends Event<'voiceStateUpdate'> {
);

if (oldChannelSecondary) {
await oldChannelSecondary.update();
try {
await oldChannelSecondary.update();
} catch (error) {
if (error instanceof DiscordAPIError) {
if (error.code === 50001) {
await oldChannelSecondary.delete();
} else if (error.code === 10003) {
await oldChannelSecondary.delete(false, true);
} else {
this.logger.error(error);
}
} else {
this.logger.error(error);
}
}
}

if (newChannelPrimary) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const channelActivities = (channel: VoiceBasedChannel) =>
.flat()
.filter((activity) => activity.type !== ActivityType.Custom)
.filter((activity) => activity.type !== ActivityType.Listening)
.map((activity) => activity.name) ?? [];
.map((activity) => activity.name)
.filter((activityName) => activityName !== 'With Yo Mamma') ?? [];

export default channelActivities;

0 comments on commit e6d8ff9

Please sign in to comment.