Split Phone into it's own manager

This commit is contained in:
Dragon Fire
2021-02-13 19:20:23 -05:00
parent 0ea5152a49
commit 592f770a35
6 changed files with 33 additions and 22 deletions
+1 -1
View File
@@ -118,7 +118,7 @@ module.exports = class PhoneCall {
if (this.cooldown.has(msg.author.id) && !this.client.isOwner(msg.author)) {
return otherChannel.send(`☎️ ${msg.author}, slow down! You're sending messages too fast!`);
}
if (this.client.isBlockedFromPhone(otherChannel, channel, msg.author)) {
if (this.client.phone.isBlocked(otherChannel, channel, msg.author)) {
return otherChannel.send(`☎️ ${msg.author}, you are blocked from sending messages to this channel!`);
}
this.setTimeout();
+23
View File
@@ -0,0 +1,23 @@
const Collection = require('@discordjs/collection');
module.exports = class PhoneManager extends Collection {
constructor(client, options) {
Object.defineProperty(this, 'client', { value: client });
super(options);
}
inCall(channel) {
return this.some(call => call.origin.id === channel.id || call.recipient.id === channel.id);
}
isBlocked(origin, recipient, caller) {
return (recipient.guild && recipient.topic.includes(`<xiao:phone:block:${origin.id}>`))
|| (recipient.guild && recipient.topic.includes(`<xiao:phone:block:${caller.id}>`))
|| (origin.guild && recipient.guild && recipient.topic.includes(`<xiao:phone:block:${origin.guild.id}>`))
|| (origin.guild && origin.topic.includes(`<xiao:phone:block:${recipient.id}>`))
|| (origin.guild && recipient.guild && origin.topic.includes(`<xiao:phone:block:${recipient.guild.id}>`))
|| (origin.guild && origin.topic.includes(`<xiao:phone:block:${caller.id}>`));
}
};