Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channels added after the bot started not recognized #8

Open
NilsKrause opened this issue May 3, 2020 · 1 comment
Open

Channels added after the bot started not recognized #8

NilsKrause opened this issue May 3, 2020 · 1 comment
Assignees

Comments

@NilsKrause
Copy link
Contributor

NilsKrause commented May 3, 2020

Small bug where the bot does not recognize channels that were added after the bot has started.
Happens because the 'gatherChannels' function only get called once when the bot starts.

discord.js has an event 'channelCreate' and 'channelDelete', so it should not be a problem to track channels in realtime too.

Will implement this in the next pull request.

@VelkanGk
Copy link

VelkanGk commented Sep 8, 2020

@NilsKrause and @LilithTheSuccubus
This can also be addressed by serching the channelID dynamically.

channel = msg.guild.channels.cache.filter((channel)=>{ return channel.name === channelName && channel.type === 'voice'; });
var channelID = "";
if(channel.size == 0){
    util.print(msg,'',"There is no such channel. Maybe you made a typo?",'red');
    return;
}else if(channel.size != 1){
    util.print(msg,'',`I have found ${channel.size} channels with the same name.\nPlease rename the channels so I can select the correct one.`,'red');
    return;
}else{
     channelID = channel.first().id;
}

With this, there's no need to have a Collection of channels, neither a gather function.
In this code I have asume that I'm searching for voice channels only and also forcing the user to have unique voice channel names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants