mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Allow phone calls with a specific channel ID
This commit is contained in:
+20
-7
@@ -12,10 +12,14 @@ module.exports = class PhoneCommand extends Command {
|
|||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'count',
|
key: 'channelID',
|
||||||
prompt: 'Would you like to get the count of channels?',
|
prompt: 'What channel would you like to start a call with?',
|
||||||
type: 'boolean',
|
type: 'string',
|
||||||
default: false
|
default: '',
|
||||||
|
validate: channelID => {
|
||||||
|
if (channelID.toLowerCase() === 'count') return true;
|
||||||
|
return !/^[0-9]+$/.test(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
credit: [
|
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>')) {
|
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.');
|
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
|
||||||
&& channel.topic.includes('<xiao:phone>')
|
&& channel.topic.includes('<xiao:phone>')
|
||||||
&& !msg.guild.channels.cache.has(channel.id));
|
&& !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...');
|
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 {
|
try {
|
||||||
const id = `${msg.channel.id}:${channel.id}`;
|
const id = `${msg.channel.id}:${channel.id}`;
|
||||||
this.client.phone.set(id, new PhoneCall(this.client, msg.channel, channel));
|
this.client.phone.set(id, new PhoneCall(this.client, msg.channel, channel));
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "112.10.0",
|
"version": "112.10.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user