I have several media channels within my Discord. Each based around different topics.
I’m trying to get it to where if a new post is made in a media channel then a text channel gets a message sent into it with a link to the new media.
I’m using a map for this as each media channel will have it’s own notifcations channel as well.
Here is the attempted script:
const gameMediaMap = new Map();
gameMediaMap.set('1236005955464986745', '1234209500437680260');
client.on('messageCreate', async (message) => {
if (gameMediaMap.has(message.channel.id)) {
const gameNotifierChannelId = gameMediaMap.get(message.channel.id);
const gameNotifierChannel = await client.channels.fetch(gameNotifierChannelId);
if (gameNotifierChannel) {
const postTags = message.content.match(/#[w-]+/g) || []; // Extract hashtags
const postTagsString = postTags.join(', ');
const messageUrl = `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`;
const notificationMessage = `A new clip was posted in <#${message.channel.id}>. [Go to clip](${messageUrl}).nVideo tagged with: '${postTagsString}'.`;
gameNotifierChannel.send(notificationMessage);
}
}
});
As it is nothing happens when a new post is made, but the rest of the bot this is attached to works flawlessly.
Any suggestions or ideas?