Add blocking of users fully from phone

This commit is contained in:
Dragon Fire
2020-12-03 15:00:33 -05:00
parent 390853e208
commit ebabd3ec75
5 changed files with 29 additions and 11 deletions
+9
View File
@@ -52,6 +52,15 @@ module.exports = class XiaoClient extends CommandoClient {
return this.phone.some(call => call.origin.id === channel.id || call.recipient.id === channel.id);
}
isBlockedFromPhone(origin, recipient, caller) {
return !recipient.topic.includes(`<xiao:phone:block:${origin.channel.id}>`)
&& !recipient.topic.includes(`<xiao:phone:block:${caller.id}>`)
&& (origin.guild ? !recipient.topic.includes(`<xiao:phone:block:${origin.guild.id}>`) : true)
&& (origin.guild ? !origin.topic.includes(`<xiao:phone:block:${recipient.channel.id}>`) : true)
&& (origin.guild ? !origin.topic.includes(`<xiao:phone:block:${recipient.guild.id}>`) : true)
&& (origin.guild ? !origin.topic.includes(`<xiao:phone:block:${caller.id}>`) : true);
}
importCommandLeaderboard() {
const read = fs.readFileSync(path.join(__dirname, '..', 'command-leaderboard.json'), {
encoding: 'utf8'
+5 -2
View File
@@ -111,9 +111,12 @@ module.exports = class PhoneCall {
}
send(channel, msg, hasText, hasImage, hasEmbed) {
const otherChannel = channel.id === this.origin.id ? this.recipient : this.origin;
if (this.cooldown.has(msg.author.id) && !this.client.isOwner(msg.author)) {
const badChannel = channel.id === this.origin.id ? this.recipient : this.origin;
return badChannel.send(`☎️ ${msg.author}, slow down! You're sending messages too fast!`);
return otherChannel.send(`☎️ ${msg.author}, slow down! You're sending messages too fast!`);
}
if (this.client.isBlockedFromPhone(otherChannel, channel, msg.author)) {
return otherChannel.send(`☎️ ${msg.author}, you are blocked from sending messages to this channel!`);
}
this.setTimeout();
if (!this.client.isOwner(msg.author)) {