Skip to content
Extraits de code Groupes Projets
Valider b07503ec rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Update presence hooks.

parent 919f9757
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -27,6 +27,7 @@ export class DiscordBot { ...@@ -27,6 +27,7 @@ export class DiscordBot {
this.bot.on("typingStop", (c, u) => { this.OnTyping(c, u, false); }); this.bot.on("typingStop", (c, u) => { this.OnTyping(c, u, false); });
this.bot.on("userUpdate", (_, newUser) => { this.UpdateUser(newUser); }); this.bot.on("userUpdate", (_, newUser) => { this.UpdateUser(newUser); });
this.bot.on("channelUpdate", (_, newChannel) => { this.UpdateRoom(<Discord.TextChannel> newChannel); }); this.bot.on("channelUpdate", (_, newChannel) => { this.UpdateRoom(<Discord.TextChannel> newChannel); });
this.bot.on("presenceUpdate", (_, newMember) => { this.UpdatePresence(newMember); });
this.bot.on("message", this.OnMessage.bind(this)); this.bot.on("message", this.OnMessage.bind(this));
this.bot.login(this.config.auth.botToken); this.bot.login(this.config.auth.botToken);
} }
...@@ -186,6 +187,23 @@ export class DiscordBot { ...@@ -186,6 +187,23 @@ export class DiscordBot {
}); });
} }
private UpdatePresence(guildMember: Discord.GuildMember) {
log.info("DiscordBot", `Updating presence for ${guildMember.user.username}#${guildMember.user.discriminator}`);
const intent = this.bridge.getIntentFromLocalpart(`_discord_${guildMember.id}`);
try {
let presence = guildMember.presence.status;
if (presence === "idle" || presence === "dnd") {
presence = "unavailable";
}
intent.getClient().setPresence({
presence,
});
} catch (err) {
log.info("DiscordBot", "Couldn't set presence ", err);
}
// TODO: Set nicknames inside the scope of guild chats.
}
private OnTyping(channel: Discord.Channel, user: Discord.User, isTyping: boolean) { private OnTyping(channel: Discord.Channel, user: Discord.User, isTyping: boolean) {
this.GetRoomIdFromChannel(channel).then((room) => { this.GetRoomIdFromChannel(channel).then((room) => {
const intent = this.bridge.getIntentFromLocalpart(`_discord_${user.id}`); const intent = this.bridge.getIntentFromLocalpart(`_discord_${user.id}`);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter