mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add blocking of users fully from phone
This commit is contained in:
@@ -25,6 +25,18 @@ module.exports = class PhoneBlockCommand extends Command {
|
||||
const search = query.toLowerCase();
|
||||
return channel.guild && (channel.name.includes(search) || channel.id === search);
|
||||
});
|
||||
let user;
|
||||
try {
|
||||
user = await this.client.users.fetch(query);
|
||||
} catch {
|
||||
user = null;
|
||||
}
|
||||
if (user) {
|
||||
return msg.say(stripIndents`
|
||||
__To block **${user.tag} (${user.id})** from DM calling and messages:__
|
||||
Place \`<xiao:phone:block:${user.id}>\` in this channel's topic
|
||||
`);
|
||||
}
|
||||
if (!channels.size) return msg.reply('Could not find any results.');
|
||||
if (channels.size > 1) return msg.reply(`Found ${channels.size} channels, please be more specific (or use ID).`);
|
||||
const channel = channels.first();
|
||||
|
||||
@@ -47,10 +47,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
&& channel.topic
|
||||
&& channel.topic.includes('<xiao:phone>')
|
||||
&& !channel.topic.includes('<xiao:phone:no-random>')
|
||||
&& !channel.topic.includes(`<xiao:phone:block:${msg.guild ? msg.channel.id : msg.author.id}>`)
|
||||
&& (msg.guild ? !channel.topic.includes(`<xiao:phone:block:${msg.guild.id}>`) : true)
|
||||
&& (msg.guild ? msg.channel.topic && !msg.channel.topic.includes(`<xiao:phone:block:${channel.id}>`) : true)
|
||||
&& (msg.guild ? msg.channel.topic && !msg.channel.topic.includes(`<xiao:phone:block:${channel.guild.id}>`) : true)
|
||||
&& !this.client.phone.isBlockedFromPhone(msg.channel, channel, msg.author)
|
||||
&& (msg.guild ? !msg.guild.channels.cache.has(channel.id) : true)
|
||||
&& (channelID ? true : !this.client.inPhoneCall(channel)));
|
||||
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
|
||||
@@ -65,12 +62,9 @@ module.exports = class PhoneCommand extends Command {
|
||||
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.');
|
||||
if (channel.topic.includes(`<xiao:phone:block:${msg.channel.id}>`)) {
|
||||
if (this.client.isBlockedFromPhone(msg.channel, channel, msg.author)) {
|
||||
return msg.reply('That channel has blocked this channel from calling them.');
|
||||
}
|
||||
if (msg.guild && channel.topic.includes(`<xiao:phone:block:${msg.guild.id}>`)) {
|
||||
return msg.reply('That channel has blocked this server from calling them.');
|
||||
}
|
||||
} else {
|
||||
channel = channels.random();
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "123.3.0",
|
||||
"version": "123.3.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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