public async Task Punish(SocketGuildUser user) { IRole role = null; using SqliteCommand command1 = new SqliteCommand(Queries.GetRoles(Context.Guild.Id), Program.sqliteConnection); using SqliteDataReader reader = await command1.ExecuteReaderAsync(); while (await reader.ReadAsync()) { role = Context.Guild.Roles.FirstOrDefault(x => x.Id == (ulong)reader.GetInt64(2)); } await reader.CloseAsync(); using SqliteCommand command = new SqliteCommand(Queries.AddPunish(Context.Guild.Id, user.Id), Program.sqliteConnection); await command.ExecuteNonQueryAsync(); try { await(user as IGuildUser).AddRoleAsync(role); } catch { Console.WriteLine("Cannot add role"); } new Events.PunishTimer(Context.Guild.Id, user.Id); await Context.Channel.SendMessageAsync(Text("punish_1") + user.Mention + Text("punish_2"), false); }
public async Task Pet(SocketGuildUser user = null) { if (user == null) { await Context.Message.AddReactionAsync(Emote.Parse("<:Aspid:567801319197245448>")); IRole dead = null; using SqliteCommand command1 = new SqliteCommand(Queries.GetRoles(Context.Guild.Id), Program.sqliteConnection); using SqliteDataReader reader1 = await command1.ExecuteReaderAsync(); while (await reader1.ReadAsync()) { dead = Context.Guild.Roles.FirstOrDefault(x => x.Id == (ulong)reader1.GetInt64(1)); } await reader1.CloseAsync(); if ((Context.User as SocketGuildUser).Roles.Contains(dead)) { await Context.Channel.SendMessageAsync(Text("pet_dead").ToString()); return; } var answers = Text("pet_answers"); int i = new Random().Next(0, answers.AllNodes.Count() - 1); if (i == 0) { Config.bot.DeadPeople++; await(Context.User as IGuildUser).AddRoleAsync(dead); } await Context.Channel.SendMessageAsync(answers[i].ToString()); } //if message has ping than pinged person is petted else { IRole dead = null; IRole punished = null; using SqliteCommand command1 = new SqliteCommand(Queries.GetRoles(Context.Guild.Id), Program.sqliteConnection); using SqliteDataReader reader1 = await command1.ExecuteReaderAsync(); while (await reader1.ReadAsync()) { dead = Context.Guild.Roles.FirstOrDefault(x => x.Id == (ulong)reader1.GetInt64(1)); punished = Context.Guild.Roles.FirstOrDefault(x => x.Id == (ulong)reader1.GetInt64(2)); } await reader1.CloseAsync(); if (user.IsBot) { await Context.Channel.SendMessageAsync(Text("pet_aspid").ToString()); return; } else if (user == Context.User) { await Context.Channel.SendMessageAsync(Text("pet_self").ToString()); return; } else if ((Context.User as SocketGuildUser).Roles.Contains(dead)) { await Context.Channel.SendMessageAsync(Text("dead_pet").ToString()); return; } else if (user.Roles.Contains(dead)) { await Context.Channel.SendMessageAsync(Text("pet_to_dead").ToString()); return; } else if (user.Roles.Contains(punished)) { await Context.Channel.SendMessageAsync(Text("pet_punished").ToString()); return; } await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() .WithColor(Color.Magenta) .WithDescription(user.Mention + Text("is_pet").ToString() + Context.User.Mention) .Build()); } }
public async Task Mute(SocketGuildUser user, string timer, [Remainder] string reason = null) { if (user.IsBot) { await Context.Message.DeleteAsync(); return; } char time = timer.Last(); string length = timer.Substring(0, timer.Length - 1); int muteTime = Convert.ToInt32(length); int outputTime = muteTime; string longitud = ""; switch (time) { case 'm': longitud = Text("minutes"); break; case 'h': muteTime *= 60; longitud = Text("hours"); break; case 'd': muteTime *= 1440; longitud = Text("days"); break; case 'w': muteTime *= 10080; longitud = Text("weeks"); break; case 'y': muteTime *= 3679200; longitud = Text("years"); break; default: return; } await Context.Channel.SendMessageAsync("🔇 " + user.Mention + Text("mute_in_channel") + muteTime + " " + longitud + "**"); using SqliteCommand command = new SqliteCommand(Queries.AddMute(Context.Guild.Id, user.Id, (ulong)muteTime), Program.sqliteConnection); await command.ExecuteNonQueryAsync(); IRole role = null; using SqliteCommand command1 = new SqliteCommand(Queries.GetRoles(Context.Guild.Id), Program.sqliteConnection); using SqliteDataReader reader = await command1.ExecuteReaderAsync(); while (await reader.ReadAsync()) { role = Context.Guild.Roles.FirstOrDefault(x => x.Id == (ulong)reader.GetInt64(3)); } await reader.CloseAsync(); await user.AddRoleAsync(role); var ls = await user.GetOrCreateDMChannelAsync(); if (reason == null) { reason = Text("mute_no_reason"); } new Events.MuteTimer(muteTime, Context.Guild.Id, user.Id); await ls.SendMessageAsync("", false, new EmbedBuilder() .WithTitle(Text("mute_head")) .WithDescription(Text("mute_1") + Context.Guild.Name + Text("mute_2") + outputTime + " " + longitud + Text("mute_3") + reason) .WithColor(Color.Red) .WithThumbnailUrl("https://media.discordapp.net/attachments/603600328117583874/615150515709411357/ezgif.com-gif-maker_31.gif") .WithCurrentTimestamp() .Build()); }