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

find channel names #97

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixclean up the name maker for the comment builder
  • Loading branch information
fax committed Nov 20, 2020
commit ba4380f2746a83df56ad6402de372bb5e8a042b3
17 changes: 5 additions & 12 deletions src/commands/modules/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,21 @@ class Bind extends Command {

static getChannelNames(server, string) {
let obj = {};
const channelNames = (server.bind || []).map((id) => {
const channelNames = (server.bind || []).forEach((id) => {
const channel = server.guild.channels.cache.get(id);

if (channel && channel.name) {
obj[channel.name] = id;
return ` ${channel.name} : ${id}`;
}

obj[id] = 'Channel Not Found';
return id;
});

if (!channelNames || !channelNames.length) {
obj = [' No Channels Bound!'];
return ' No Channels Bound!';
}

return {
string: '\n' + channelNames.join('\n') + '\n',
object: obj,
};
return obj;
}

usage(input, server) {
Expand All @@ -46,7 +41,7 @@ class Bind extends Command {
return input.response(
CommentBuilder.create({
data: {
[usage]: Bind.getChannelNames(server).object,
[usage]: Bind.getChannelNames(server),
'Auto permitting': [server.bindPermit ? 'Turned ON' : ' Turned OFF'],
commands: {
[command]: server.lang('bindusage.noargs'),
Expand Down Expand Up @@ -98,12 +93,10 @@ class Bind extends Command {
input.response(
CommentBuilder.create({
data: {
[usage]: Bind.getChannelNames(server).object,
[usage]: Bind.getChannelNames(server),
},
}),
);
} else {
input.il8nResponse('bind.current', { bound: Bind.getChannelNames(server).string });
}
}

Expand Down