const logEvent = (
c: Client,
{
embed,
logOutputChannelID,
canvasString,
}: {
embed: any;
logOutputChannelID?: string;
canvasString?: string;
}
) => {
console.log("logEvent ran");
if (!logOutputChannelID) return;
const logOutputChannel = c.channels.cache.get(
logOutputChannelID
) as TextChannel;
if (logOutputChannel) {
if (canvasString) {
const attachment = new AttachmentBuilder(
Buffer.from(canvasString.split(",")[1], "base64"),
{ name: "currentDice.png" }
);
logOutputChannel.send({
embeds: [
{
image: {
url: "attachment://currentDice.png",
},
},
],
files: [attachment],
});
} else {
logOutputChannel
.send({
embeds: [embed],
})
.catch((err: Error) => console.error(err));
}
}
};
console.log("shard", discord?.shard);
discord?.shard
?.broadcastEval(logEvent, {
context: {
embed: generateEmbed(),
logOutputChannelID,
canvasString,
},
})
// .then(console.log)
.catch(console.error);
};
const logEvent = (
c: Client,
{
embed,
logOutputChannelID,
canvasString,
}: {
embed: any;
logOutputChannelID?: string;
canvasString?: string;
}
) => {
console.log("logEvent ran");
if (!logOutputChannelID) return;
const logOutputChannel = c.channels.cache.get(
logOutputChannelID
) as TextChannel;
if (logOutputChannel) {
if (canvasString) {
const attachment = new AttachmentBuilder(
Buffer.from(canvasString.split(",")[1], "base64"),
{ name: "currentDice.png" }
);
logOutputChannel.send({
embeds: [
{
image: {
url: "attachment://currentDice.png",
},
},
],
files: [attachment],
});
} else {
logOutputChannel
.send({
embeds: [embed],
})
.catch((err: Error) => console.error(err));
}
}
};
console.log("shard", discord?.shard);
discord?.shard
?.broadcastEval(logEvent, {
context: {
embed: generateEmbed(),
logOutputChannelID,
canvasString,
},
})
// .then(console.log)
.catch(console.error);
};