Acrophobia and weather fixes
This commit is contained in:
parent
c5376f999e
commit
e8d8134321
@ -24,7 +24,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Acro(IUserMessage imsg, int time = 45)
|
public async Task Acro(IUserMessage imsg, int time = 60)
|
||||||
{
|
{
|
||||||
var channel = (ITextChannel)imsg.Channel;
|
var channel = (ITextChannel)imsg.Channel;
|
||||||
|
|
||||||
@ -67,6 +67,8 @@ namespace NadekoBot.Modules.Games
|
|||||||
private readonly ConcurrentDictionary<string, IGuildUser> submissions = new ConcurrentDictionary<string, IGuildUser>();
|
private readonly ConcurrentDictionary<string, IGuildUser> submissions = new ConcurrentDictionary<string, IGuildUser>();
|
||||||
public IReadOnlyDictionary<string, IGuildUser> Submissions => submissions;
|
public IReadOnlyDictionary<string, IGuildUser> Submissions => submissions;
|
||||||
|
|
||||||
|
private readonly ConcurrentHashSet<ulong> usersWhoVoted = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
private int spamCount = 0;
|
private int spamCount = 0;
|
||||||
|
|
||||||
//text, votes
|
//text, votes
|
||||||
@ -136,7 +138,10 @@ namespace NadekoBot.Modules.Games
|
|||||||
}
|
}
|
||||||
else if (submissions.Count == 1)
|
else if (submissions.Count == 1)
|
||||||
{
|
{
|
||||||
await channel.SendConfirmAsync("Acrophobia", $"{submissions.First().Value.Mention} is the winner for being the only user who made a submission!").ConfigureAwait(false);
|
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
|
.WithDescription($"{submissions.First().Value.Mention} is the winner for being the only user who made a submission!")
|
||||||
|
.WithFooter(efb => efb.WithText(submissions.First().Key.ToLowerInvariant().ToTitleCase()))
|
||||||
|
.Build()).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var submissionClosedEmbed = GetEmbed();
|
var submissionClosedEmbed = GetEmbed();
|
||||||
@ -226,9 +231,27 @@ namespace NadekoBot.Modules.Games
|
|||||||
IGuildUser usr;
|
IGuildUser usr;
|
||||||
if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id)
|
if (submissions.TryGetValue(input, out usr) && usr.Id != guildUser.Id)
|
||||||
{
|
{
|
||||||
|
if (!usersWhoVoted.Add(guildUser.Id))
|
||||||
|
return;
|
||||||
votes.AddOrUpdate(input, 1, (key, old) => ++old);
|
votes.AddOrUpdate(input, 1, (key, old) => ++old);
|
||||||
await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false);
|
await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false);
|
||||||
await msg.DeleteAsync().ConfigureAwait(false);
|
await msg.DeleteAsync().ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int num;
|
||||||
|
if (int.TryParse(input, out num) && num >= 0 && num < submissions.Count)
|
||||||
|
{
|
||||||
|
var kvp = submissions.Skip(num).First();
|
||||||
|
usr = kvp.Value;
|
||||||
|
if (usr.Id == guildUser.Id)
|
||||||
|
return;
|
||||||
|
if (!usersWhoVoted.Add(guildUser.Id))
|
||||||
|
return;
|
||||||
|
votes.AddOrUpdate(kvp.Key, 1, (key, old) => ++old);
|
||||||
|
await channel.SendConfirmAsync("Acrophobia", $"{guildUser.Mention} cast their vote!").ConfigureAwait(false);
|
||||||
|
await msg.DeleteAsync().ConfigureAwait(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace NadekoBot.Modules.Searches.Commands.Models
|
|||||||
public class Wind
|
public class Wind
|
||||||
{
|
{
|
||||||
public double speed { get; set; }
|
public double speed { get; set; }
|
||||||
public int deg { get; set; }
|
public double deg { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Clouds
|
public class Clouds
|
||||||
|
@ -96,7 +96,7 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 45).
|
/// Looks up a localized string similar to Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 60).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string acro_desc {
|
public static string acro_desc {
|
||||||
get {
|
get {
|
||||||
|
@ -2794,7 +2794,7 @@
|
|||||||
<value>acro</value>
|
<value>acro</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="acro_desc" xml:space="preserve">
|
<data name="acro_desc" xml:space="preserve">
|
||||||
<value>Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 45)</value>
|
<value>Starts an Acrophobia game. Second argment is optional round length in seconds. (default is 60)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="acro_usage" xml:space="preserve">
|
<data name="acro_usage" xml:space="preserve">
|
||||||
<value>`{0}acro` or `{0}acro 30`</value>
|
<value>`{0}acro` or `{0}acro 30`</value>
|
||||||
|
Loading…
Reference in New Issue
Block a user