mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
const Command = require('../../structures/Command');
|
|
const { stripIndents } = require('common-tags');
|
|
|
|
module.exports = class PhoneBookCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'phone-book',
|
|
group: 'other',
|
|
memberName: 'phone-book',
|
|
description: 'Looks up phone-enabled servers.',
|
|
guildOnly: true,
|
|
args: [
|
|
{
|
|
key: 'query',
|
|
prompt: 'What server would you like to search for?',
|
|
type: 'string'
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
run(msg, { query }) {
|
|
const channels = this.client.channels.cache.filter(channel => {
|
|
const search = query.toLowerCase();
|
|
return channel.guild
|
|
&& channel.topic
|
|
&& channel.topic.includes('<xiao:phone>')
|
|
&& !channel.topic.includes('<xiao:phone-book:hide>')
|
|
&& (channel.guild.name.toLowerCase().includes(search) || channel.name.includes(search));
|
|
});
|
|
if (!channels.size) return msg.reply('Could not find any results.');
|
|
return msg.say(stripIndents`
|
|
__**Results:**__ _(${channels.size} Results)_
|
|
${channels.map(c => `**${c.id}** (#${c.name}: ${c.guild.name})`).slice(0, 10).join('\n')}
|
|
`);
|
|
}
|
|
};
|