.voicepresence added - closes #26
This commit is contained in:
parent
83f224d9d5
commit
e8adbde9d7
@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Discord;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Commands {
|
||||
class LogCommand : DiscordCommand {
|
||||
@ -16,7 +17,9 @@ namespace NadekoBot.Commands {
|
||||
|
||||
ConcurrentDictionary<Server, Channel> logs = new ConcurrentDictionary<Server, Channel>();
|
||||
ConcurrentDictionary<Server, Channel> loggingPresences = new ConcurrentDictionary<Server, Channel>();
|
||||
|
||||
//
|
||||
ConcurrentDictionary<Channel, Channel> voiceChannelLog = new ConcurrentDictionary<Channel, Channel>();
|
||||
|
||||
public override Func<CommandEventArgs, Task> DoFunc() => async e => {
|
||||
if (e.User.Id != NadekoBot.OwnerID ||
|
||||
!e.User.ServerPermissions.ManageServer)
|
||||
@ -76,6 +79,18 @@ namespace NadekoBot.Commands {
|
||||
}
|
||||
catch { }
|
||||
|
||||
try {
|
||||
if (e.Before.VoiceChannel != null && voiceChannelLog.ContainsKey(e.Before.VoiceChannel)) {
|
||||
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
||||
await voiceChannelLog[e.Before.VoiceChannel].SendMessage($"🎼`{e.Before.Name} has left the` {e.Before.VoiceChannel.Mention} `voice channel.`");
|
||||
}
|
||||
if (e.After.VoiceChannel != null && voiceChannelLog.ContainsKey(e.After.VoiceChannel)) {
|
||||
if (e.After.VoiceChannel != e.Before.VoiceChannel)
|
||||
await voiceChannelLog[e.After.VoiceChannel].SendMessage($"🎼`{e.After.Name} has joined the`{e.After.VoiceChannel.Mention} `voice channel.`");
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
try {
|
||||
Channel ch;
|
||||
if (!logs.TryGetValue(e.Server, out ch))
|
||||
@ -113,6 +128,26 @@ namespace NadekoBot.Commands {
|
||||
|
||||
await e.Channel.SendMessage($"**User presence notifications disabled.**");
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".voicepresence")
|
||||
.Description("Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now.")
|
||||
.Do(async e => {
|
||||
if (e.User.Id != NadekoBot.OwnerID ||
|
||||
!e.User.ServerPermissions.ManageServer)
|
||||
return;
|
||||
|
||||
if (e.User.VoiceChannel == null) {
|
||||
await e.Channel.SendMessage("💢 You are not in a voice channel right now. If you are, please rejoin it.");
|
||||
return;
|
||||
}
|
||||
Channel throwaway;
|
||||
if (!voiceChannelLog.TryRemove(e.User.VoiceChannel, out throwaway)) {
|
||||
voiceChannelLog.TryAdd(e.User.VoiceChannel, e.Channel);
|
||||
await e.Channel.SendMessage($"`Logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`");
|
||||
}
|
||||
else
|
||||
await e.Channel.SendMessage($"`Stopped logging user updates for` {e.User.VoiceChannel.Mention} `voice channel.`");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user