mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Only allow phone calls to one channel at a time
This commit is contained in:
@@ -27,7 +27,7 @@ module.exports = class BlackjackCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { deckCount }) { // eslint-disable-line complexity
|
async run(msg, { deckCount }) {
|
||||||
const current = this.client.games.get(msg.channel.id);
|
const current = this.client.games.get(msg.channel.id);
|
||||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ module.exports = class HangmanCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(msg) { // eslint-disable-line complexity
|
async run(msg) {
|
||||||
const current = this.client.games.get(msg.channel.id);
|
const current = this.client.games.get(msg.channel.id);
|
||||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||||
this.client.games.set(msg.channel.id, { name: this.name });
|
this.client.games.set(msg.channel.id, { name: this.name });
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ module.exports = class AdminPhoneCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { channelID }) {
|
async run(msg, { channelID }) {
|
||||||
const inCall = this.client.phone.some(call => [call.origin.id, call.recipient.id].includes(msg.channel.id));
|
if (this.client.inPhoneCall(msg.channel)) return msg.say('This channel is already in a phone call.');
|
||||||
if (inCall) return msg.say('This channel is already in a phone call.');
|
|
||||||
const channel = this.client.channels.cache.get(channelID);
|
const channel = this.client.channels.cache.get(channelID);
|
||||||
if (!channel || !channel.guild) return msg.reply('This channel does not exist.');
|
if (!channel || !channel.guild) return msg.reply('This channel does not exist.');
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ module.exports = class PhoneCommand extends Command {
|
|||||||
if (channelID !== 'count' && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>'))) {
|
if (channelID !== 'count' && (!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.');
|
||||||
}
|
}
|
||||||
const inCall = this.client.phone.some(call => [call.origin.id, call.recipient.id].includes(msg.channel.id));
|
if (channelID !== 'count' && this.client.inPhoneCall(msg.channel)) {
|
||||||
if (channelID !== 'count' && inCall) {
|
|
||||||
return msg.say('This channel is already in a phone call.');
|
return msg.say('This channel is already in a phone call.');
|
||||||
}
|
}
|
||||||
const channels = this.client.channels.cache.filter(channel => channel.guild
|
const channels = this.client.channels.cache.filter(channel => channel.guild
|
||||||
&& 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)
|
||||||
|
&& (channelID ? true : !this.client.inPhoneCall(channel)));
|
||||||
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
|
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
|
||||||
let channel;
|
let channel;
|
||||||
if (channelID) {
|
if (channelID) {
|
||||||
@@ -58,6 +58,7 @@ module.exports = class PhoneCommand extends Command {
|
|||||||
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {
|
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {
|
||||||
return msg.reply('This channel does not allow phone calls.');
|
return msg.reply('This channel does not allow phone calls.');
|
||||||
}
|
}
|
||||||
|
if (this.client.inPhoneCall(channel)) return msg.reply('This channel is already in a call.');
|
||||||
} else {
|
} else {
|
||||||
channel = channels.random();
|
channel = channels.random();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "114.13.1",
|
"version": "114.13.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -33,4 +33,8 @@ module.exports = class XiaoClient extends CommandoClient {
|
|||||||
this.activities = activities;
|
this.activities = activities;
|
||||||
this.leaveMessages = leaveMsgs;
|
this.leaveMessages = leaveMsgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inPhoneCall(channel) {
|
||||||
|
return this.phone.some(call => call.origin.id === channel.id || call.recipient.id === channel.id);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user