Skip to content

Commit

Permalink
Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunami014 committed Dec 6, 2023
1 parent 8b05c24 commit b5e45ab
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions .github/scripts/notifyDiscord.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ let previousMessage = null;

client.once(Events.ClientReady, (readyClient) => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);

const channel = readyClient.channels.cache.get('1181875066280091688'); // Replace with your channel ID

if (channel) {
channel.messages.fetch({ limit: 1 })
.then(messages => {
previousMessage = messages.last(); // Get the second-to-last message
console.log(`Previous message: ${previousMessage.content}`);
})
.catch(error => console.error(`Error fetching messages: ${error}`));
// Send a new message in the same channel
const newMessageContent = 'Hello, this is a new message!';
channel.send(newMessageContent);
console.log(`Sent message: ${newMessageContent}`)
channel.messages.fetch({ limit: 1 })
.then(messages => {
previousMessage = messages.last(); // Get the second-to-last message
console.log(`Previous message: ${previousMessage.content}`);
// Send a new message in the same channel
const newMessageContent = 'Hello, this is a new message!';
channel.send(initialMessageContent)
.then(() => {
console.log('Initial message sent successfully. Exiting the bot process.');
channel.messages.fetch({ limit: 1 })
.then(messages => {
previousMessage = messages.last(); // Get the second-to-last message
console.log(`Previous message: ${previousMessage.content}`);
process.exit(); // Exit the process after sending the message
})
.catch(error => console.error(`Error fetching messages: ${error}`));

})
.catch(error => {
console.error(`Error sending message: ${error}`);
});
})
.catch(error => console.error(`Error fetching messages: ${error}`));
}
Expand Down

0 comments on commit b5e45ab

Please sign in to comment.