.whosplaying code cleanup
This commit is contained in:
parent
58e59a208f
commit
ba993a1bab
3 changed files with 31 additions and 22 deletions
|
@ -8,6 +8,4 @@ public class UserXpStats : DbEntity
|
||||||
public long Xp { get; set; }
|
public long Xp { get; set; }
|
||||||
public long AwardedXp { get; set; }
|
public long AwardedXp { get; set; }
|
||||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum XpNotificationLocation { None, Dm, Channel }
|
|
7
src/EllieBot/Db/Models/xp/XpNotificationLocation.cs
Normal file
7
src/EllieBot/Db/Models/xp/XpNotificationLocation.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace EllieBot.Db.Models;
|
||||||
|
|
||||||
|
public enum XpNotificationLocation
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Dm,
|
||||||
|
}
|
|
@ -112,28 +112,32 @@ public partial class Utility : EllieModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rng = new EllieRandom();
|
|
||||||
var arr = await Task.Run(() => socketGuild.Users
|
|
||||||
.Where(u => u.Activities.Any(x
|
|
||||||
=> x.Name is not null && x.Name.ToUpperInvariant() == game))
|
|
||||||
.Select(u => u.Username)
|
|
||||||
.OrderBy(_ => rng.Next())
|
|
||||||
.Take(60)
|
|
||||||
.ToArray());
|
|
||||||
|
|
||||||
var i = 0;
|
var userNames = new List<IUser>(socketGuild.Users.Count / 100);
|
||||||
if (arr.Length == 0)
|
foreach (var user in socketGuild.Users)
|
||||||
await Response().Error(strs.nobody_playing_game).SendAsync();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
await Response()
|
if (user.Activities.Any(x => x.Name is not null && x.Name.ToUpperInvariant() == game))
|
||||||
.Confirm("```css\n"
|
{
|
||||||
+ string.Join("\n",
|
userNames.Add(user);
|
||||||
arr.GroupBy(_ => i++ / 2)
|
}
|
||||||
.Select(ig => string.Concat(ig.Select(el => $"• {el,-27}"))))
|
|
||||||
+ "\n```")
|
|
||||||
.SendAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userNames.Shuffle();
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
if (userNames.Count == 0)
|
||||||
|
{
|
||||||
|
await Response().Error(strs.nobody_playing_game).SendAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var users = userNames.GroupBy(_ => i++ / 2)
|
||||||
|
.Select(ig => string.Concat(ig.Select(el => $"• {el,-27}")))
|
||||||
|
.Join('\n');
|
||||||
|
|
||||||
|
await Response()
|
||||||
|
.Confirm(Format.Code(users))
|
||||||
|
.SendAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
|
Loading…
Reference in a new issue