Skip to content

Commit

Permalink
Remove logs, add camera notif & add activity
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdevey committed Nov 7, 2021
1 parent 644195a commit e7eee3d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ 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 @@ -24,6 +24,7 @@ export class Bot {
token: string;
intents: Intents[];
commands: Command[];
ready: (client: Client) => void;

constructor(token: string, intents: Intents[], commands: Command[]) {
this.token = token;
Expand All @@ -33,9 +34,10 @@ export class Bot {

public listen(ready: (client: Client) => void) {
this.client = new Client({ intents: this.intents });
this.ready = ready;
this.client.login(this.token);
this.onInteraction();
ready(this.client);
this.onReady();
}

public vcUpdate(respond: (before: VoiceState, after: VoiceState) => void) {
Expand All @@ -58,4 +60,10 @@ export class Bot {
});
}

private onReady() {
this.client.on("ready", client => {
this.ready(this.client);
});
}

}
11 changes: 7 additions & 4 deletions src/stateUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,38 @@ export function stateUpdate(discord, before, updated) {
if(before.channel == undefined && updated.channel != undefined) {

// User joined a VC
console.log(`${member.user.tag} JOINED ${updated.channel.name}`);
return send(discord, `${member.displayName} just joined ${updated.channel.name}`, `🎧`, member, updateChannel);

}

if(before.channel != undefined && updated.channel == undefined) {

// User left a VC
console.log(`${member.user.tag} LEFT ${before.channel.name}`);
return send(discord, `${member.displayName} just left ${before.channel.name}`, `🚪`, member, updateChannel);

}

if(before.channel != undefined && updated.channel != undefined && before.channel != updated.channel) {

// User switched VCs
console.log(`${member.user.tag} SWITCHED TO ${updated.channel.name}`);
return send(discord, `${member.displayName} just switched to ${updated.channel.name}`, `🔄️`, member, updateChannel);

}

if(updated.streaming) {

// User is streaming
console.log(`${member.user.tag} IS LIVE IN ${updated.channel.name}`);
return send(discord, `${member.displayName} is live in ${updated.channel.name}`, `🔴`, member, updateChannel);

}

if(updated.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 e7eee3d

Please sign in to comment.