mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-16 00:12:32 +02:00
Add hang up as a command
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class HangUpCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'hang-up',
|
||||
group: 'phone',
|
||||
memberName: 'hang-up',
|
||||
description: 'Hangs up the current phone call.',
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
const origin = client.phone.find(call => call.origin.id === msg.channel.id);
|
||||
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
||||
if (!origin && !recipient) return msg.reply('☎️ This channel is not in a phone call.');
|
||||
const call = origin || recipient;
|
||||
if (!call.active) return msg.reply('☎️ This call is not currently active.');
|
||||
if (call.ownerOrigin && !this.client.isOwner(msg.author)) {
|
||||
return msg.reply('☎️ You cannot hang up in an admin call.');
|
||||
}
|
||||
const nonQuitter = msg.channel.id === call.origin.id ? call.recipient : call.origin;
|
||||
await call.hangup(nonQuitter);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user