mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Forgot to remove portal
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class AddPortalChannelCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'add-portal-channel',
|
||||
aliases: ['set-portal-channel', 'portal-channel', 'open-portal'],
|
||||
group: 'portal',
|
||||
memberName: 'add-channel',
|
||||
description: 'Sets a channel to be a portal channel.',
|
||||
guildOnly: true,
|
||||
userPermissions: ['MANAGE_CHANNELS'],
|
||||
args: [
|
||||
{
|
||||
key: 'channel',
|
||||
prompt: 'What channel do you want to set as a portal channel?',
|
||||
type: 'channel',
|
||||
default: msg => msg.channel
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { channel }) {
|
||||
if (channel.type !== 'text') return msg.reply('Only text channels can have a portal!');
|
||||
const channels = this.client.provider.get('global', 'portals', []);
|
||||
if (channels.includes(channel.id)) return msg.reply(`${channel} already has an open portal!`);
|
||||
channels.push(channel.id);
|
||||
this.client.provider.set('global', 'portals', channels);
|
||||
return msg.say(`A portal opened in ${channel}!`);
|
||||
}
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class FixPortalChannelsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fix-portal-channels',
|
||||
aliases: ['fix-portals'],
|
||||
group: 'portal',
|
||||
memberName: 'fix-channels',
|
||||
description: 'Removes no longer existent channels from the portal list.',
|
||||
ownerOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const channels = this.client.provider.get('global', 'portals', []);
|
||||
let count = 0;
|
||||
for (const channel of channels) {
|
||||
if (this.client.channels.has(channel)) continue;
|
||||
channels.splice(channels.indexOf(channel), 1);
|
||||
count++;
|
||||
}
|
||||
if (!channels.length) this.client.provider.remove('global', 'portals');
|
||||
else this.client.provider.set('global', 'portals', channels);
|
||||
return msg.say(`Cleared **${count}** channels from the portal list.`);
|
||||
}
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class RemovePortalChannelCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'remove-portal-channel',
|
||||
aliases: ['delete-portal-channel', 'close-portal'],
|
||||
group: 'portal',
|
||||
memberName: 'remove-channel',
|
||||
description: 'Remove a channel from the portal channels.',
|
||||
guildOnly: true,
|
||||
userPermissions: ['MANAGE_CHANNELS'],
|
||||
args: [
|
||||
{
|
||||
key: 'channel',
|
||||
prompt: 'What channel do you want to remove from the portal channels?',
|
||||
type: 'channel',
|
||||
default: msg => msg.channel
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { channel }) {
|
||||
if (channel.type !== 'text') return msg.reply('Only text channels can have a portal!');
|
||||
const channels = this.client.provider.get('global', 'portals', []);
|
||||
if (!channels.includes(channel.id)) return msg.reply(`${channel} does not have an open portal!`);
|
||||
channels.splice(channels.indexOf(channel.id), 1);
|
||||
if (!channels.length) this.client.provider.remove('global', 'portals');
|
||||
else this.client.provider.set('global', 'portals', channels);
|
||||
return msg.say(`The portal in ${channel} closed...`);
|
||||
}
|
||||
};
|
||||
@@ -1,22 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class PortalStatusCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'portal-status',
|
||||
group: 'portal',
|
||||
memberName: 'status',
|
||||
description: 'Shows the number of currently opened portals.'
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const channels = this.client.provider.get('global', 'portals', []);
|
||||
const local = msg.channel.type === 'text' ? channels.filter(c => msg.guild.channels.has(c)).length : 0;
|
||||
return msg.say(
|
||||
`There are currently **${channels.length}** open portals${msg.channel.type === 'text'
|
||||
? `, **${local}** of which are in this server.`
|
||||
: '.'}`
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -5,8 +5,8 @@ module.exports = class PortalSendCommand extends Command {
|
||||
super(client, {
|
||||
name: 'portal-send',
|
||||
aliases: ['send-portal-message', 'portal-message', 'send-portal-msg', 'portal-msg'],
|
||||
group: 'portal',
|
||||
memberName: 'send',
|
||||
group: 'text-edit',
|
||||
memberName: 'portal-send',
|
||||
description: 'Send a message to a portal channel.',
|
||||
args: [
|
||||
{
|
||||
@@ -21,10 +21,12 @@ module.exports = class PortalSendCommand extends Command {
|
||||
|
||||
async run(msg, { message }) {
|
||||
if (/discord(\.gg|app\.com\/invite|\.me)\//gi.test(message)) return msg.reply('Please do not send invites.');
|
||||
let channels = this.client.provider.get('global', 'portals', []).filter(c => this.client.channels.has(c));
|
||||
let channels = this.client.channels.filter(
|
||||
channel => channel.type === 'text' && channel.topic && channel.topic.includes('<portal>')
|
||||
);
|
||||
if (msg.channel.type === 'text') channels = channels.filter(channel => !msg.guild.channels.has(channel));
|
||||
if (!channels.length) return msg.reply('No channels have an open portal...');
|
||||
const channel = this.client.channels.get(channels[Math.floor(Math.random() * channels.length)]);
|
||||
if (!channels.size) return msg.reply('No channels have an open portal...');
|
||||
const channel = channels.random();
|
||||
try {
|
||||
await channel.send(`**${msg.author.tag} (${msg.channel.type !== 'text' ? 'DM' : msg.guild.name})**: ${message}`);
|
||||
return msg.say(`Message sent to **${channel.name}** in **${channel.guild.name}**!`);
|
||||
Reference in New Issue
Block a user