Beispiel #1
0
        public async Task Amt(SocketGuildUser targetUser, [Remainder] string thing)
        {
            var ds  = new DataStorage <AmtObject>("Storage/AmtStorage.json");
            var amt = new AmtObject {
                User = targetUser, Thing = thing.ToLower()
            };
            ushort percentage = 0;

            var listOfMatching = from a in ds.ReturnList()
                                 where a.Equals(amt)
                                 select a;
            bool exists = listOfMatching.Any();

            // If the object doesn't already exist in storage
            if (!exists)
            {
                percentage = (ushort)R.Next(101);
                amt.Value  = percentage;
                ds.Add(amt);
            }

            var obj = from a in ds.ReturnList()
                      where a.Equals(amt)
                      select a.Value;

            percentage = obj.FirstOrDefault();

            await Context.Channel.SendMessageAsync($"{GetNickname(targetUser)} is {percentage}% {thing}");
        }
Beispiel #2
0
 public bool Equals(AmtObject obj)
 {
     return(User == obj.User && Thing == obj.Thing);
 }