Skip to content

Commit

Permalink
update node.js and discord.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf committed Aug 30, 2021
1 parent 3f8fdb3 commit 33de89c
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 64 deletions.
22 changes: 12 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const Discord = require('discord.js');
const { Client, Intents, MessageEmbed } = require('discord.js');
require('dotenv').config();

const client = new Discord.Client();
const client = new Client({
intents: [
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILDS
]
});

const regurl = /https:\/\/discord(app)?.com\/channels(\/\d{18}){3}/g;

client.on('ready', () => console.log(`Logged in as ${client.user.tag}!`));

client.on('message', msg => {
client.on('messageCreate', msg => {
if (msg.author.bot) return;
let msgurls = msg.content.match(regurl);
if (!msgurls) return;
Expand Down Expand Up @@ -37,7 +42,7 @@ client.on('message', msg => {
}else{
channel_name = cnl.name;
}
let msgembed = new Discord.MessageEmbed({
let msgembed = new MessageEmbed({
author: {
name: name,
icon_url: target.author.avatarURL()
Expand All @@ -53,12 +58,9 @@ client.on('message', msg => {
if (attach) msgembed.setImage(attach.url);
let embeds = target.embeds;
if (embeds.length) msgembed.description += `\n(${embeds.length} ${embeds.length == 1 ? 'embed follows.' : 'embeds follow.'})`;
msg.channel.send(msgembed)
.catch(e => console.error(e));
for (let embed of embeds) {
msg.channel.send(embed)
.catch(e => console.error(e));
};
msg.channel.send({
embeds: [msgembed].concat(embeds)
}).catch(e => console.error(e));
}).catch(e => console.error(e));
};
});
Expand Down
Loading

0 comments on commit 33de89c

Please sign in to comment.