Allow phone calls with a specific channel ID

This commit is contained in:
Dragon Fire
2020-03-19 12:48:17 -04:00
parent d9c19cfad6
commit 453456a4c8
2 changed files with 21 additions and 8 deletions
+20 -7
View File
@@ -12,10 +12,14 @@ module.exports = class PhoneCommand extends Command {
guildOnly: true,
args: [
{
key: 'count',
prompt: 'Would you like to get the count of channels?',
type: 'boolean',
default: false
key: 'channelID',
prompt: 'What channel would you like to start a call with?',
type: 'string',
default: '',
validate: channelID => {
if (channelID.toLowerCase() === 'count') return true;
return !/^[0-9]+$/.test(val);
}
}
],
credit: [
@@ -28,7 +32,7 @@ module.exports = class PhoneCommand extends Command {
});
}
async run(msg, { count }) {
async run(msg, { channelID }) {
if (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')) {
return msg.say('You can only start a call in a channel with `<xiao:phone>` in the topic.');
}
@@ -39,9 +43,18 @@ module.exports = class PhoneCommand extends Command {
&& channel.topic
&& channel.topic.includes('<xiao:phone>')
&& !msg.guild.channels.cache.has(channel.id));
if (count) return msg.say(`☎️ **${channels.size}** currently open lines.`);
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
const channel = channels.random();
let channel;
if (channelID) {
if (channelID.toLowerCase() === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
channel = this.client.channels.cache.get(channelID);
if (!channel || channel.type !== 'text') return msg.reply('This channel does not exist.');
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {
return msg.reply('This channel does not allow phone calls.');
}
} else {
channel = channels.random();
}
try {
const id = `${msg.channel.id}:${channel.id}`;
this.client.phone.set(id, new PhoneCall(this.client, msg.channel, channel));
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "112.10.0",
"version": "112.10.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {