From c99d2a9bba112bc79943d80cc5e5781e1ce152fa Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 4 Jan 2017 16:53:39 +0100 Subject: [PATCH] Added .setstatus --- .../Modules/Administration/Administration.cs | 1 - .../Administration/Commands/SelfCommands.cs | 11 +++++++- .../Resources/CommandStrings.Designer.cs | 27 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++++ src/NadekoBot/ShardedDiscordClient.cs | 27 +++++++++++++++++++ 5 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 4532a9f5..5b97b69a 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -485,7 +485,6 @@ namespace NadekoBot.Modules.Administration { var sb = new StringBuilder(); var msgs = new List(cnt); - await Context.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)).ConfigureAwait(false); var title = $"Chatlog-{Context.Guild.Name}/#{Context.Channel.Name}-{DateTime.Now}.txt"; diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs index 589fa49a..be2643a3 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -59,7 +59,16 @@ namespace NadekoBot.Modules.Administration await NadekoBot.Client.CurrentUser().ModifyAsync(u => u.Username = newName).ConfigureAwait(false); - await Context.Channel.SendConfirmAsync($"ℹ️ Successfully changed name to **{newName}**").ConfigureAwait(false); + await Context.Channel.SendConfirmAsync($"Bot name changed to **{newName}**").ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [OwnerOnly] + public async Task SetStatus([Remainder] SettableUserStatus status) + { + await NadekoBot.Client.SetStatus(status); + + await Context.Channel.SendConfirmAsync($"Bot status changed to **{status}**").ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 368dc408..4858f768 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6566,6 +6566,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to setstatus. + /// + public static string setstatus_cmd { + get { + return ResourceManager.GetString("setstatus_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sets the bot's status. (Online/Idle/Invisible). + /// + public static string setstatus_desc { + get { + return ResourceManager.GetString("setstatus_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}setstatus Idle`. + /// + public static string setstatus_usage { + get { + return ResourceManager.GetString("setstatus_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to setstream. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 3eb5f456..8c9ee0bf 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2853,4 +2853,13 @@ `{0}autohentai 30 yuri|tail|long_hair` or `{0}autohentai` + + setstatus + + + Sets the bot's status. (Online/Idle/Invisible) + + + `{0}setstatus Idle` + \ No newline at end of file diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index aee2af7b..4948eb92 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -140,5 +140,32 @@ namespace NadekoBot public Task SetStream(string name, string url) => Task.WhenAll(Clients.Select(ms => ms.SetGameAsync(name, url, StreamType.NotStreaming))); + + public Task SetStatus(SettableUserStatus status) => Task.WhenAll(Clients.Select(ms => ms.SetStatusAsync(SettableUserStatusToUserStatus(status)))); + + private static UserStatus SettableUserStatusToUserStatus(SettableUserStatus sus) + { + switch (sus) + { + case SettableUserStatus.Online: + return UserStatus.Online; + case SettableUserStatus.Invisible: + return UserStatus.Invisible; + case SettableUserStatus.Idle: + return UserStatus.AFK; + } + + return UserStatus.Online; + } + } + + public enum SettableUserStatus + { + Online = 1, + On = 1, + Invisible = 2, + Invis = 2, + Idle = 3, + Afk = 3 } } \ No newline at end of file