async function sendMessage(
channelId: Snowflake,
guildId: Snowflake,
client: Client,
data: data,
timestamp: number,
roles: [Snowflake?],
) {
const guildroles = roles.length ? [...new Set(roles)] : roles;
if (data) {
const embed = new EmbedBuilder()
.setColor('#0e48b8')
.setTitle(data.name)
.setDescription(data.description)
.setTimestamp(timestamp);
(client.guilds.cache.get(guildId)?.channels.cache.get(channelId) as TextBasedChannel)
.send({
content: guildroles?.length ? guildroles.map((g) => `<@&${g}>`).join(' ') : '',
embeds: [embed],
})
.then((m) => console.log(process.pid, '[Discord.js]', 'Sent data to channel:', m.channelId))
.catch((e: any) => {
console.log(e);
});
}
}
async function sendMessage(
channelId: Snowflake,
guildId: Snowflake,
client: Client,
data: data,
timestamp: number,
roles: [Snowflake?],
) {
const guildroles = roles.length ? [...new Set(roles)] : roles;
if (data) {
const embed = new EmbedBuilder()
.setColor('#0e48b8')
.setTitle(data.name)
.setDescription(data.description)
.setTimestamp(timestamp);
(client.guilds.cache.get(guildId)?.channels.cache.get(channelId) as TextBasedChannel)
.send({
content: guildroles?.length ? guildroles.map((g) => `<@&${g}>`).join(' ') : '',
embeds: [embed],
})
.then((m) => console.log(process.pid, '[Discord.js]', 'Sent data to channel:', m.channelId))
.catch((e: any) => {
console.log(e);
});
}
}