diff --git a/NadekoBot/Classes/Trivia.cs b/NadekoBot/Classes/Trivia.cs index 4309a442..8ce194fd 100644 --- a/NadekoBot/Classes/Trivia.cs +++ b/NadekoBot/Classes/Trivia.cs @@ -13,10 +13,10 @@ namespace NadekoBot { public class Trivia : DiscordCommand { - public static Dictionary runningTrivias; + public static Dictionary runningTrivias; public Trivia() : base() { - runningTrivias = new Dictionary(); + runningTrivias = new Dictionary(); } public static TriviaGame StartNewGame(CommandEventArgs e) { @@ -29,7 +29,7 @@ namespace NadekoBot return tg; } - public TriviaQuestion GetCurrentQuestion(long serverId) => runningTrivias[serverId].currentQuestion; + public TriviaQuestion GetCurrentQuestion(ulong serverId) => runningTrivias[serverId].currentQuestion; public override Func DoFunc() => async e => { @@ -103,12 +103,12 @@ namespace NadekoBot public class TriviaGame { private DiscordClient client; - private long _serverId; - private long _channellId; + private ulong _serverId; + private ulong _channellId; - public long ChannelId => _channellId; + public ulong ChannelId => _channellId; - private Dictionary users; + private Dictionary users; public List oldQuestions; @@ -121,7 +121,7 @@ namespace NadekoBot private bool isQuit = false; public TriviaGame(CommandEventArgs starter, DiscordClient client) { - this.users = new Dictionary(); + this.users = new Dictionary(); this.client = client; this._serverId = starter.Server.Id; this._channellId= starter.Channel.Id; @@ -196,7 +196,7 @@ namespace NadekoBot if (currentQuestion == null || isQuit) { - await ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard()); + ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard()); FinishGame(); return; } diff --git a/NadekoBot/Classes/_JSONModels.cs b/NadekoBot/Classes/_JSONModels.cs index 30e13761..8a5b8467 100644 --- a/NadekoBot/Classes/_JSONModels.cs +++ b/NadekoBot/Classes/_JSONModels.cs @@ -6,13 +6,12 @@ public string Password; public string BotMention; public string GoogleAPIKey; - public long OwnerID; + public ulong OwnerID; public bool Crawl; public string ParseID; public string ParseKey; } - - class AnimeResult + public class AnimeResult { public int id; public string airing_status; @@ -21,15 +20,14 @@ public string description; public string image_url_lge; - public override string ToString() => + public override string ToString() => "`Title:` **" + title_english + "**\n`Status:` " + airing_status + "\n`Episodes:` " + total_episodes + "\n`Link:` http://anilist.co/anime/" + id + "\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." + "\n`img:` " + image_url_lge; - } - + } class MangaResult { public int id; @@ -40,7 +38,7 @@ public int total_volumes; public string description; - public override string ToString() => + public override string ToString() => "`Title:` **" + title_english + "**\n`Status:` " + publishing_status + "\n`Chapters:` " + total_chapters + diff --git a/NadekoBot/Commands/CopyCommand.cs b/NadekoBot/Commands/CopyCommand.cs index 5f3657dd..7d782e07 100644 --- a/NadekoBot/Commands/CopyCommand.cs +++ b/NadekoBot/Commands/CopyCommand.cs @@ -7,11 +7,11 @@ namespace NadekoBot { class CopyCommand : DiscordCommand { - private List CopiedUsers; + private List CopiedUsers; public CopyCommand() : base() { - CopiedUsers = new List(); + CopiedUsers = new List(); client.MessageReceived += Client_MessageReceived; } diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs index 9e3c5acc..4dde8c3e 100644 --- a/NadekoBot/Modules/Administration.cs +++ b/NadekoBot/Modules/Administration.cs @@ -241,10 +241,14 @@ namespace NadekoBot.Modules .Parameter("user",Discord.Commands.ParameterType.Required) .Do(async e => { - if (e.Message.MentionedUsers.Any()) - await e.Send( "Id of the user " + e.Message.MentionedUsers.First().Mention + " is " + e.Message.MentionedUsers.First().Id); - else - await e.Send( "You must mention a user."); + var usr = client.FindUsers(e.Channel, e.GetArg("user")).FirstOrDefault(); + if (usr == null) + { + await e.Send("You must mention a user."); + return; + } + + await e.Send( "Id of the user " + usr.Name + " is " + usr.Id); }); cgb.CreateCommand(".cid").Alias(".channelid") diff --git a/NadekoBot/Modules/Games.cs b/NadekoBot/Modules/Games.cs index 92ff63f6..7a169ad4 100644 --- a/NadekoBot/Modules/Games.cs +++ b/NadekoBot/Modules/Games.cs @@ -94,7 +94,7 @@ namespace NadekoBot.Modules } } - private PokeType GetType(long id) { + private PokeType GetType(ulong id) { var remainder = id % 10; if (remainder < 3) return PokeType.WATER; diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 088eb8ea..5f4612cc 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -22,6 +22,81 @@ namespace NadekoBot.Modules } + class EditUserBuilder { + + public Discord.DiscordClient Client { get; set; } + public Discord.User User { get; set; } + private bool? ShouldMute { get; set; } + private bool? ShouldDeaf { get; set; } + private Discord.Channel TargetVoiceChannel { get; set; } + private Dictionary> TargetRoles { get; set; } + + + public EditUserBuilder(Discord.User user, Discord.DiscordClient client = null) { + this.User = user; + this.Client = client; + TargetRoles = new Dictionary>(); + } + + public EditUserBuilder Mute(bool mute = true) { + ShouldMute = mute; + return this; + } + + public EditUserBuilder Deaf(bool mute = true) + { + ShouldDeaf = mute; + return this; + } + + public EditUserBuilder VoiceChannel(Discord.Channel voiceChannel = null) + { + TargetVoiceChannel = voiceChannel; + return this; + } + + public EditUserBuilder Roles(IEnumerable roles, Discord.EditMode mode) + { + if (TargetRoles.Keys.Contains(mode)) + { + TargetRoles[mode] = TargetRoles[mode].Concat(roles); + } + else + { + TargetRoles[mode] = roles; + } + return this; + } + + public async Task Apply() { + if (Client == null || User == null) return; //throw exception? + await Client.EditUser(User, ShouldMute, ShouldDeaf, TargetVoiceChannel); + foreach (var mode in TargetRoles.Keys) { + await Client.EditUser(User, null, null, null, TargetRoles[mode], mode); + } + return; + } + + public EditUserBuilder SetUser(Discord.User user) + { + this.User = user; + return this; + } + + public EditUserBuilder SetClient(Discord.DiscordClient client) + { + this.Client = client; + return this; + } + + public EditUserBuilder DoWhen(Func func, Func predicate) { + if (predicate()) + return func(this); + return this; + } + + } + public override void Install(ModuleManager manager) { var client = NadekoBot.client; diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index 9627f3da..c2b3a285 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -15,7 +15,7 @@ namespace NadekoBot // public static StatsCollector stats_collector; public static string botMention; public static string GoogleAPIKey; - public static long OwnerID; + public static ulong OwnerID; static void Main() { diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 72fab195..f8552f42 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -48,18 +48,6 @@ 4 - - E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.dll - - - E:\Ostalo\Discord.Net\src\Discord.Net.Audio.Net5\bin\Debug\Discord.Net.Audio.dll - - - E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.Commands.dll - - - E:\Ostalo\Discord.Net\src\Discord.Net.Modules.Net45\bin\Debug\Discord.Net.Modules.dll - ..\packages\VideoLibrary.1.3.1\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\libvideo.dll True @@ -138,6 +126,24 @@ false + + + {7bfef748-b934-4621-9b11-6302e3a9f6b3} + Discord.Net.Audio + + + {1b5603b4-6f8f-4289-b945-7baae523d740} + Discord.Net.Commands + + + {3091164f-66ae-4543-a63d-167c1116241d} + Discord.Net.Modules + + + {8d71a857-879a-4a10-859e-5ff824ed6688} + Discord.Net + +