Skip to content

Commit

Permalink
Merge pull request #7 from BanDev/fix-multiple-notifs-bug
Browse files Browse the repository at this point in the history
Fix bug where multiple notifications are sent
  • Loading branch information
jackdevey authored Nov 7, 2021
2 parents e7eee3d + 3162de4 commit 81867d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 2 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const Discord = require("discord.js");
const intents = [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_MESSAGES
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGES
];

const commands: Command[] = [
Expand All @@ -53,8 +54,6 @@ bot.listen(function (client: Client) {
console.log("BanDev | 1.0.0");
console.log("===");
console.log("AWAITING COMMANDS...");

client.user.setActivity('bandev.uk/notify', { type: 'PLAYING' });
});

// When something changes in a
Expand Down
10 changes: 9 additions & 1 deletion src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class Bot {
this.ready = ready;
this.client.login(this.token);
this.onInteraction();
this.onMessage();
this.onReady();
}

Expand All @@ -62,7 +63,14 @@ export class Bot {

private onReady() {
this.client.on("ready", client => {
this.ready(this.client);
client.user.setActivity('bandev.uk/notify', { type: 'PLAYING' });
this.ready(client);
});
}

private onMessage() {
this.client.on("messageCreate", async message => {
console.log(message)
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/stateUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export function stateUpdate(discord, before, updated) {

}

if(updated.streaming) {
if(updated.streaming && !before.streaming) {

// User is streaming
return send(discord, `${member.displayName} is live in ${updated.channel.name}`, `🔴`, member, updateChannel);

}

if(updated.selfVideo) {
if(updated.selfVideo && !before.selfVideo) {

// User has camera on
return send(discord, `${member.displayName} turned their camera on in ${updated.channel.name}`, `📷`, member, updateChannel);
Expand Down

0 comments on commit 81867d2

Please sign in to comment.