Skip to content

Commit

Permalink
fixed non hook version
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-flip committed Sep 23, 2024
1 parent 1c3af33 commit 112f707
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions commands/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ function getChannels() {
.catch(ERR);
}

async function sendMessage(author, body) {
const channels = await getChannels();
channels.forEach((DBchannel) => {
const channelID = DBchannel.logChannelID;
const channel = client.channels.cache.find((channel) => channel.id === channelID);
async function sendMessage(channel, author, body) {
const embed = new MessageEmbed()
.setAuthor({ name: `${author} broadcasted` })
.setDescription(body)
.setColor(4182379);
channel.send({ embeds: [embed] });
});
}

module.exports.run = async (interaction) => {
Expand All @@ -37,14 +32,14 @@ module.exports.run = async (interaction) => {
let errCreateWebhook = false;
const channelWebhooks = await channel.fetchWebhooks().catch((err) => {
errCreateWebhook = true;
return sendMessage(interaction.user.tag, body);
return sendMessage(channel, interaction.user.tag, body);
});
if (errCreateWebhook) return;
let hook = channelWebhooks.find((hook) => hook.owner.id === client.user.id);
if (!hook) {
hook = await channel.createWebhook(config.name).catch((err) => {
errCreateWebhook = true;
return sendMessage(interaction.user.tag, body);
return sendMessage(channel, interaction.user.tag, body);
});
}
if (errCreateWebhook) return;
Expand Down

0 comments on commit 112f707

Please sign in to comment.