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