mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
Add blocking of users fully from phone
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user