mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 21:44:48 +02:00
Split Phone into it's own manager
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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}>`));
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user