mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 21:40:51 +02:00
ownerOrigin -> adminCall
This commit is contained in:
@@ -110,9 +110,9 @@ client.on('message', async msg => {
|
|||||||
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
||||||
if (!origin && !recipient) return;
|
if (!origin && !recipient) return;
|
||||||
const call = origin || recipient;
|
const call = origin || recipient;
|
||||||
if (!call.ownerOrigin && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>'))) return;
|
if (!call.adminCall && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>'))) return;
|
||||||
if (!call.active) return;
|
if (!call.active) return;
|
||||||
if (call.ownerOrigin && msg.guild.id === call.origin.guild.id && !client.isOwner(msg.author)) return;
|
if (call.adminCall && msg.guild.id === call.origin.guild.id && !client.isOwner(msg.author)) return;
|
||||||
try {
|
try {
|
||||||
await call.send(origin ? call.recipient : call.origin, msg, hasText, hasImage, hasEmbed);
|
await call.send(origin ? call.recipient : call.origin, msg, hasText, hasImage, hasEmbed);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module.exports = class HangUpCommand extends Command {
|
|||||||
if (!origin && !recipient) return msg.reply('☎️ This channel is not in a phone call.');
|
if (!origin && !recipient) return msg.reply('☎️ This channel is not in a phone call.');
|
||||||
const call = origin || recipient;
|
const call = origin || recipient;
|
||||||
if (!call.active) return msg.reply('☎️ This call is not currently active.');
|
if (!call.active) return msg.reply('☎️ This call is not currently active.');
|
||||||
if (call.ownerOrigin && !this.client.isOwner(msg.author)) {
|
if (call.adminCall && !this.client.isOwner(msg.author)) {
|
||||||
return msg.reply('☎️ You cannot hang up in an admin call.');
|
return msg.reply('☎️ You cannot hang up in an admin call.');
|
||||||
}
|
}
|
||||||
const nonQuitter = msg.channel.id === call.origin.id ? call.recipient : call.origin;
|
const nonQuitter = msg.channel.id === call.origin.id ? call.recipient : call.origin;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module.exports = class PhoneInfoCommand extends Command {
|
|||||||
.addField('❯ Recipient Server', otherChannel.guild.name, true)
|
.addField('❯ Recipient Server', otherChannel.guild.name, true)
|
||||||
.addField('❯ Recipient ID', otherChannel.id, true)
|
.addField('❯ Recipient ID', otherChannel.id, true)
|
||||||
.addField('❯ Call Duration', call.durationDisplay, true)
|
.addField('❯ Call Duration', call.durationDisplay, true)
|
||||||
.addField('❯ Admin Call?', call.ownerOrigin ? 'Yes' : 'No', true)
|
.addField('❯ Admin Call?', call.adminCall ? 'Yes' : 'No', true)
|
||||||
.addField('❯ Started By', call.startUser.tag, true);
|
.addField('❯ Started By', call.startUser.tag, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ require('moment-duration-format');
|
|||||||
const { shorten, stripInvites, verify } = require('../../util/Util');
|
const { shorten, stripInvites, verify } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class PhoneCall {
|
module.exports = class PhoneCall {
|
||||||
constructor(client, startUser, origin, recipient, ownerOrigin) {
|
constructor(client, startUser, origin, recipient, adminCall) {
|
||||||
Object.defineProperty(this, 'client', { value: client });
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
this.id = `${origin.id}:${recipient.id}`;
|
this.id = `${origin.id}:${recipient.id}`;
|
||||||
@@ -13,14 +13,14 @@ module.exports = class PhoneCall {
|
|||||||
this.startUser = startUser;
|
this.startUser = startUser;
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.timeout = null;
|
this.timeout = null;
|
||||||
this.ownerOrigin = ownerOrigin || false;
|
this.adminCall = adminCall || false;
|
||||||
this.cooldown = new Set();
|
this.cooldown = new Set();
|
||||||
this.ratelimitMeters = new Map();
|
this.ratelimitMeters = new Map();
|
||||||
this.timeStarted = null;
|
this.timeStarted = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
if (this.ownerOrigin) {
|
if (this.adminCall) {
|
||||||
await this.origin.send(`☎️ Admin call started with **${this.recipient.guild.name}**.`);
|
await this.origin.send(`☎️ Admin call started with **${this.recipient.guild.name}**.`);
|
||||||
await this.recipient.send(`☎️ An **ADMIN** call from **${this.origin.guild.name}** has begun.`);
|
await this.recipient.send(`☎️ An **ADMIN** call from **${this.origin.guild.name}** has begun.`);
|
||||||
} else {
|
} else {
|
||||||
@@ -40,7 +40,7 @@ module.exports = class PhoneCall {
|
|||||||
this.active = true;
|
this.active = true;
|
||||||
this.timeStarted = new Date();
|
this.timeStarted = new Date();
|
||||||
this.setTimeout();
|
this.setTimeout();
|
||||||
if (this.ownerOrigin) return this;
|
if (this.adminCall) return this;
|
||||||
const usage = this.client.registry.commands.get('hang-up').usage();
|
const usage = this.client.registry.commands.get('hang-up').usage();
|
||||||
await this.origin.send(`☎️ **${this.recipient.guild.name}** picked up! Use ${usage} to hang up.`);
|
await this.origin.send(`☎️ **${this.recipient.guild.name}** picked up! Use ${usage} to hang up.`);
|
||||||
await this.recipient.send(`☎️ Accepted call from **${this.origin.guild.name}**. Use ${usage} to hang up.`);
|
await this.recipient.send(`☎️ Accepted call from **${this.origin.guild.name}**. Use ${usage} to hang up.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user