From a39d136826dd9c28f7958c0f1c476f3b233cba47 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 9 Nov 2017 08:49:24 +0100 Subject: [PATCH] Added .raffleany - it will include users who are not online, too --- NadekoBot.Core/Modules/Gambling/Gambling.cs | 16 ++++++++++++++++ src/NadekoBot/data/command_strings.json | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/NadekoBot.Core/Modules/Gambling/Gambling.cs b/NadekoBot.Core/Modules/Gambling/Gambling.cs index 11e79fef..9defa74f 100644 --- a/NadekoBot.Core/Modules/Gambling/Gambling.cs +++ b/NadekoBot.Core/Modules/Gambling/Gambling.cs @@ -107,6 +107,22 @@ namespace NadekoBot.Modules.Gambling await Context.Channel.SendConfirmAsync("🎟 "+ GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task RaffleAny([Remainder] IRole role = null) + { + role = role ?? Context.Guild.EveryoneRole; + + var members = (await role.GetMembersAsync()); + var membersArray = members as IUser[] ?? members.ToArray(); + if (membersArray.Length == 0) + { + return; + } + var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)]; + await Context.Channel.SendConfirmAsync("🎟 " + GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] [Priority(1)] public async Task Cash([Remainder] IUser user = null) diff --git a/src/NadekoBot/data/command_strings.json b/src/NadekoBot/data/command_strings.json index eff19a26..3b44ba3c 100644 --- a/src/NadekoBot/data/command_strings.json +++ b/src/NadekoBot/data/command_strings.json @@ -940,12 +940,20 @@ }, "raffle": { "Cmd": "raffle", - "Desc": "Prints a name and ID of a random user from the online list from the (optional) role.", + "Desc": "Prints a name and ID of a random online user from the server, or from the online user in the specified role.", "Usage": [ "{0}raffle", "{0}raffle RoleName" ] }, + "raffleany": { + "Cmd": "raffleany", + "Desc": "Prints a name and ID of a random user from the server, or from the specified role.", + "Usage": [ + "{0}raffleany", + "{0}raffleany RoleName" + ] + }, "give": { "Cmd": "give", "Desc": "Give someone a certain amount of currency.",