Compare commits

..

No commits in common. "403cefc7372ab67dfcc51b50150be985e89dd1d4" and "7c3eb13e2818d15b8c928c24c1fb7df7984a27f6" have entirely different histories.

2 changed files with 0 additions and 65 deletions

View file

@ -1,64 +0,0 @@
import { GuildBasedChannel, Message } from 'discord.js';
/** https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-messageCreate */
export default (message: Message) => {
// Ignore message if
if (
// Author is a bot
message.author.bot ||
// Author is Discord
message.author.system ||
// Message isn't a message
message.system ||
// Message is in PM (future-proof if we add Intents.FLAGS.DIRECT_MESSAGES)
!message.guild ||
// Guild is offline
!message.guild.available
) {
return;
}
/* Citation */
const regex = 'https://(?:canary\\.|ptb\\.)?discord(?:app)?\\.com/channels/(\\d{17,19})/(\\d{17,19})/(\\d{17,19})';
const urls = message.content.match(new RegExp(regex, 'g'));
// Ignore message if there is no URLs
if (!urls) {
return;
}
const messages = (
urls.reduce(
(data: {
message_id: string;
found_channel: GuildBasedChannel;
}[] = [], match) => {
const [,
guild_id,
channel_id,
message_id,
] = new RegExp(regex).exec(match) as RegExpExecArray;
// If message posted in another guild
if (guild_id !== message.guild?.id) {
return data;
}
const found_channel =
message.guild.channels.cache.get(channel_id);
// If channel doesn't exist in the guild
if (!found_channel) {
return data;
}
data.push({ message_id, found_channel });
return data;
},
[]
)
);
console.log(messages);
};

View file

@ -45,7 +45,6 @@ export default async () => {
const client: Client = new Client({ const client: Client = new Client({
intents: [ intents: [
Intents.FLAGS.GUILDS, Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
], ],
}); });