public async Task UserJoinedOrLeftChannel(SocketUser user, SocketVoiceState voiceState1, SocketVoiceState voiceState2) { var account = UserAccounts.GetAccount(user); //adding xp for joining/leaving voice channel string voiceState1String = voiceState1.ToString(); TimeSpan timeDif = DateTime.Now.Subtract(account.TimeConnected); Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $" : {user} connected to {voiceState2} from {voiceState1}"); if (voiceState1String != "Unknown" && voiceState1String != "AFK") { int i = 0; double timeDiffMinutes = timeDif.TotalMinutes; while (timeDiffMinutes >= 3) { UserLeveling.AddXp(user, 1); //adding XP timeDiffMinutes -= 3; i++; } UserLeveling.TotalTimeConntected(user); //adding total minutes to account if (timeDif.TotalMinutes > 3) { Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $" : {user} gained {i * 1} XP by staying in {voiceState1} for {timeDif.TotalMinutes}"); } } UserLeveling.LastActivity(user); //setting new LastActivity }
public async Task userSendMessage(SocketMessage s) { var msg = s as SocketUserMessage; var context = new SocketCommandContext(_client, msg); //adding xp for sending message UserLeveling.AddXpAndCheckLevel(context.User, context.Guild, 3); }
public async Task addXp(uint xp) { var GuildUser = await((IGuild)Context.Guild).GetUserAsync(Context.User.Id); if (admins.Contains(GuildUser.Id)) { var embed = new EmbedBuilder(); rnd = new Random(); embed.WithColor(new Color(rnd.Next(255), rnd.Next(255), rnd.Next(255))); UserLeveling.AddXpAndCheckLevel(Context.User, Context.Guild, xp); await Context.Channel.SendMessageAsync($"Added {xp} xp", false, embed); Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $" : Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User} || Used: ?AddXp"); } }