mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Fix
This commit is contained in:
@@ -22,7 +22,7 @@ module.exports = class MockingCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, { text }) {
|
||||
const canEmoji = msg.channel.type === 'text'
|
||||
const canEmoji = msg.guild
|
||||
? msg.channel.permissionsFor(this.client.user).has('USE_EXTERNAL_EMOJIS')
|
||||
: true;
|
||||
const letters = text.split('');
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = class SayCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
|
||||
if (msg.guild && msg.deletable) await msg.delete();
|
||||
return msg.say(text);
|
||||
} catch {
|
||||
return msg.say(text);
|
||||
|
||||
@@ -23,7 +23,7 @@ module.exports = class WebhookCommand extends Command {
|
||||
|
||||
async run(msg, { content }) {
|
||||
try {
|
||||
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
|
||||
if (msg.guild && msg.deletable) await msg.delete();
|
||||
await this.client.webhook.send(content);
|
||||
return null;
|
||||
} catch (err) {
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = class FirstMessageCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { channel }) {
|
||||
if (channel.type === 'text' && !channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY')) {
|
||||
if (msg.guild && !channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY')) {
|
||||
return msg.reply(`Sorry, I don't have permission to read ${channel}...`);
|
||||
}
|
||||
const messages = await channel.messages.fetch({ after: 1, limit: 1 });
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = class UserCommand extends Command {
|
||||
• Discord Join Date: ${moment.utc(user.createdAt).format('MM/DD/YYYY h:mm A')}
|
||||
• ${user.bot ? 'Bot' : 'Not a Bot'}
|
||||
`;
|
||||
if (msg.channel.type === 'text') {
|
||||
if (msg.guild) {
|
||||
try {
|
||||
const member = await msg.guild.members.fetch(user.id);
|
||||
const defaultRole = msg.guild.roles.cache.get(msg.guild.id);
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = class CleverbotCommand extends Command {
|
||||
|
||||
async run(msg, { text }, fromPattern) {
|
||||
if (fromPattern) {
|
||||
if (this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
if (msg.guild && this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
text = msg.patternMatches[2];
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = class PhoneBookCommand extends Command {
|
||||
run(msg, { query }) {
|
||||
const channels = this.client.channels.cache.filter(channel => {
|
||||
const search = query.toLowerCase();
|
||||
return channel.type === 'text'
|
||||
return channel.guild
|
||||
&& channel.topic
|
||||
&& channel.topic.includes('<xiao:phone>')
|
||||
&& !channel.topic.includes('<xiao:phone-book:hide>')
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
if (channelID !== 'count' && inCall) {
|
||||
return msg.say('This channel is already in a phone call.');
|
||||
}
|
||||
const channels = this.client.channels.cache.filter(channel => channel.type === 'text'
|
||||
const channels = this.client.channels.cache.filter(channel => channel.guild
|
||||
&& channel.topic
|
||||
&& channel.topic.includes('<xiao:phone>')
|
||||
&& !msg.guild.channels.cache.has(channel.id));
|
||||
@@ -54,7 +54,7 @@ module.exports = class PhoneCommand extends Command {
|
||||
if (channelID) {
|
||||
if (channelID === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
|
||||
channel = this.client.channels.cache.get(channelID);
|
||||
if (!channel || channel.type !== 'text') return msg.reply('This channel does not exist.');
|
||||
if (!channel || !channel.guild) return msg.reply('This channel does not exist.');
|
||||
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {
|
||||
return msg.reply('This channel does not allow phone calls.');
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ 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.channels.cache.filter(
|
||||
channel => channel.type === 'text' && channel.topic && channel.topic.includes('<xiao:portal>')
|
||||
channel => channel.guild && channel.topic && channel.topic.includes('<xiao:portal>')
|
||||
);
|
||||
if (msg.channel.type === 'text') {
|
||||
if (channel.guild) {
|
||||
channels = channels.filter(channel => !msg.guild.channels.cache.has(channel.id));
|
||||
}
|
||||
if (message.toLowerCase() === 'count') {
|
||||
@@ -38,7 +38,7 @@ module.exports = class PortalSendCommand extends Command {
|
||||
if (!channels.size) return msg.reply('No channels have an open portal...');
|
||||
const channel = channels.random();
|
||||
try {
|
||||
const displayName = msg.channel.type === 'text' ? msg.guild.name : 'DM';
|
||||
const displayName = msg.guild ? msg.guild.name : 'DM';
|
||||
await channel.send(`**${this.portalEmoji} ${msg.author.tag} (${displayName}):** ${message}`);
|
||||
return msg.say(`Message sent to **${channel.name}** in **${channel.guild.name}**!`);
|
||||
} catch {
|
||||
|
||||
@@ -34,7 +34,8 @@ module.exports = class HelpCommand extends Command {
|
||||
const commands = group.commands.filter(cmd => {
|
||||
if (owner) return true;
|
||||
if (cmd.ownerOnly || cmd.hidden) return false;
|
||||
if (this.client.botListGuilds.includes(msg.guild.id) && cmd instanceof AutoReplyCommand) {
|
||||
const inBotList = msg.guild && this.client.botListGuilds.includes(msg.guild.id);
|
||||
if (inBotList && cmd instanceof AutoReplyCommand) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,8 +16,8 @@ module.exports = class UnknownCommandCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
if (msg.channel.type !== 'text') return null;
|
||||
if (this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
if (!msg.guild) return null;
|
||||
if (msg.guild && this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
const commands = this.makeCommandArray(this.client.isOwner(msg.author), msg.channel.nsfw);
|
||||
const command = msg.content.match(this.client.dispatcher._commandPatterns[this.client.commandPrefix]);
|
||||
const str = command ? command[2] : msg.content.split(' ')[0];
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = class AutoReplyCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, args, fromPattern) {
|
||||
if (this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
if (msg.guild && this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
return this.reply ? msg.reply(this.generateText(fromPattern)) : msg.say(this.generateText(fromPattern));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = class SubredditCommand extends Command {
|
||||
|
||||
async run(msg, { subreddit }, fromPattern) {
|
||||
if (fromPattern) {
|
||||
if (this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
if (msg.guild && this.client.botListGuilds.includes(msg.guild.id)) return null;
|
||||
subreddit = msg.patternMatches[1];
|
||||
}
|
||||
if (!subreddit) subreddit = typeof this.subreddit === 'function' ? this.subreddit() : this.subreddit;
|
||||
|
||||
Reference in New Issue
Block a user