mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 15:57:43 +02:00
DM Phone Calls
This commit is contained in:
@@ -110,7 +110,7 @@ client.on('message', async msg => {
|
||||
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
||||
if (!origin && !recipient) return;
|
||||
const call = origin || recipient;
|
||||
if (!call.adminCall && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>'))) return;
|
||||
if (!call.adminCall && (msg.guild && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')))) return;
|
||||
if (!call.active) return;
|
||||
if (call.adminCall && msg.guild.id === call.origin.guild.id && !client.isOwner(msg.author)) return;
|
||||
try {
|
||||
|
||||
@@ -9,7 +9,6 @@ module.exports = class AdminPhoneCommand extends Command {
|
||||
group: 'phone',
|
||||
memberName: 'admin-phone',
|
||||
description: 'Starts an admin phone call with a server.',
|
||||
guildOnly: true,
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ module.exports = class PhoneBookCommand extends Command {
|
||||
group: 'phone',
|
||||
memberName: 'phone-book',
|
||||
description: 'Looks up phone-enabled servers.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
|
||||
@@ -8,8 +8,7 @@ module.exports = class PhoneInfoCommand extends Command {
|
||||
aliases: ['call-info', 'phone-call-info'],
|
||||
group: 'phone',
|
||||
memberName: 'phone-info',
|
||||
description: 'Gives information on the current phone call.',
|
||||
guildOnly: true
|
||||
description: 'Gives information on the current phone call.'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,11 +19,13 @@ module.exports = class PhoneInfoCommand extends Command {
|
||||
const call = origin || recipient;
|
||||
if (!call.active) return msg.reply('☎️ This call is not currently active.');
|
||||
const otherChannel = msg.channel.id === call.origin.id ? call.recipient : call.origin;
|
||||
const otherChannelDM = msg.channel.id === call.origin.id ? false : Boolean(call.origin.guild);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.setThumbnail(otherChannel.guild.iconURL({ format: 'png' }))
|
||||
.addField('❯ Recipient Channel', `#${otherChannel.name}`, true)
|
||||
.addField('❯ Recipient Server', otherChannel.guild.name, true)
|
||||
.addField('❯ Recipient Channel',
|
||||
otherChannelDM ? `@${call.origin.startUser.tag}` : `#${otherChannel.name}`, true)
|
||||
.addField('❯ Recipient Server', otherChannelDM ? 'DM' : otherChannel.guild.name, true)
|
||||
.addField('❯ Recipient ID', otherChannel.id, true)
|
||||
.addField('❯ Call Duration', call.durationDisplay, true)
|
||||
.addField('❯ Admin Call?', call.adminCall ? 'Yes' : 'No', true)
|
||||
|
||||
@@ -9,7 +9,6 @@ module.exports = class PhoneCommand extends Command {
|
||||
group: 'phone',
|
||||
memberName: 'phone',
|
||||
description: 'Starts a phone call with a random server.',
|
||||
guildOnly: true,
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 45
|
||||
@@ -38,7 +37,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { channelID }) {
|
||||
if (channelID !== 'count' && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>'))) {
|
||||
if (channelID !== 'count' && (msg.guild && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')))) {
|
||||
return msg.say('You can only start a call in a channel with `<xiao:phone>` in the topic.');
|
||||
}
|
||||
if (channelID !== 'count' && this.client.inPhoneCall(msg.channel)) {
|
||||
@@ -68,7 +67,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
return msg.reply('That channel has blocked this channel from calling them.');
|
||||
}
|
||||
if (channel.topic.includes(`<xiao:phone:block:${msg.guild.id}>`)) {
|
||||
return msg.replY('That channel has blocked this server from calling them.');
|
||||
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.0.4",
|
||||
"version": "123.0.5",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = class PhoneCall {
|
||||
|
||||
this.id = `${origin.id}:${recipient.id}`;
|
||||
this.origin = origin;
|
||||
this.originDM = !Boolean(origin.guild);
|
||||
this.recipient = recipient;
|
||||
this.startUser = startUser;
|
||||
this.active = false;
|
||||
@@ -22,10 +23,18 @@ module.exports = class PhoneCall {
|
||||
async start() {
|
||||
if (this.adminCall) {
|
||||
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.`);
|
||||
if (this.originDM) {
|
||||
await this.recipient.send(`☎️ An **ADMIN** call from **${this.startUser.tag}'s DMs** has begun.`);
|
||||
} else {
|
||||
await this.recipient.send(`☎️ An **ADMIN** call from **${this.origin.guild.name}** has begun.`);
|
||||
}
|
||||
} else {
|
||||
await this.origin.send(`☎️ Calling **${this.recipient.guild.name} (${this.recipient.id})**...`);
|
||||
await this.recipient.send(`☎️ Incoming call from **${this.origin.guild.name} (${this.origin.id})**. Pick up?`);
|
||||
if (this.originDM) {
|
||||
await this.recipient.send(`☎️ Incoming call from **${this.startUser.tag}'s DM (${this.origin.id})**. Pick up?`);
|
||||
} else {
|
||||
await this.recipient.send(`☎️ Incoming call from **${this.origin.guild.name} (${this.origin.id})**. Pick up?`);
|
||||
}
|
||||
const validation = await verify(this.recipient, null);
|
||||
if (!validation) {
|
||||
await this.hangup('declined', validation);
|
||||
@@ -43,7 +52,11 @@ module.exports = class PhoneCall {
|
||||
if (this.adminCall) return this;
|
||||
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.recipient.send(`☎️ Accepted call from **${this.origin.guild.name}**. Use ${usage} to hang up.`);
|
||||
if (this.originDM) {
|
||||
await this.recipient.send(`☎️ Accepted call from **${this.startUser.tag}'s DM**. Use ${usage} to hang up.`);
|
||||
} else {
|
||||
await this.recipient.send(`☎️ Accepted call from **${this.origin.guild.name}**. Use ${usage} to hang up.`);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -84,7 +97,11 @@ module.exports = class PhoneCall {
|
||||
}
|
||||
} else {
|
||||
const quitter = nonQuitter.id === this.origin.id ? this.recipient : this.origin;
|
||||
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
if (quitter.guild) {
|
||||
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
} else {
|
||||
await nonQuitter.send(`☎️ **${this.startUser.tag}** hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
}
|
||||
await quitter.send(`☎️ Hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
}
|
||||
this.client.phone.delete(this.id);
|
||||
@@ -121,7 +138,7 @@ module.exports = class PhoneCall {
|
||||
|
||||
sendVoicemail(channel, msg) {
|
||||
return channel.send(stripIndents`
|
||||
☎️ New Voicemail from **${msg.guild.name}:**
|
||||
☎️ New Voicemail from **${this.originDM ? `${this.startUser.tag}'s DMs` : this.origin.guild.name}:**
|
||||
**${msg.author.tag}:** ${stripInvites(msg.content)}
|
||||
`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user