public async Task HandleJoin(SocketGuildUser user) { ulong ID = user.Guild.Id; IChannel chan = user.Guild.GetChannel(Constants.Channels.EARTH_GEN); if (ID == Constants.Guilds.DBZ_EARTH) { chan = user.Guild.GetChannel(Constants.Channels.EARTH_GEN); } else if (ID == Constants.Guilds.DBZ_NAMEK) { chan = user.Guild.GetChannel(Constants.Channels.NAMEK_GEN); } else if (ID == Constants.Guilds.DBZ_VEGETA) { chan = user.Guild.GetChannel(Constants.Channels.VEGETA_GEN); } var mChan = chan as IMessageChannel; string reg = ""; if (DBFuncs.PlayerRegistered(user)) { DBFuncs.LoadRoles(user); } else { reg = " Use `db!register [race]` to register as either a Human, Namekian, or Saiyan."; } await mChan.SendMessageAsync($"{user.Mention} has entered {user.Guild.Name.Replace("DBZ ", "")}.{reg}"); }
public async Task Register(string race) { race = race.ToLower(); if (DBFuncs.PlayerRegistered(Context.User)) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} has already registered."); } else if (race == "human" || race == "saiyan" || race == "namekian") { Player.Race wRace = Player.Race.Human; string planet = ""; if (race == "human") { wRace = Player.Race.Human; planet = "Earth: https://discord.gg/UwDKgAF"; } else if (race == "saiyan") { wRace = Player.Race.Saiyan; planet = "Vegeta: https://discord.gg/vFaS8u2"; } else if (race == "namekian") { wRace = Player.Race.Namekian; planet = "Namek: https://discord.gg/tJVfgms"; } string[] toWrite = new string[9]; toWrite[0] = Context.User.Username; toWrite[1] = $"RACE: {wRace}"; toWrite[2] = "POWER_LVL: 10"; toWrite[3] = "MULTIPLIER: 1"; toWrite[4] = "ENERGY: 100"; toWrite[5] = "LEVEL: 1"; toWrite[6] = "EXP: 0"; toWrite[7] = "LOCATION: null"; toWrite[8] = "SKILLS:"; File.WriteAllLines($@"Players\{Context.User.Id}.txt", toWrite); DBFuncs.LoadRoles(Context.User); await Context.Channel.SendMessageAsync($"{Context.User.Mention} has successfully registered as a {wRace}. Go forth to Planet {planet}."); } else { await Context.Channel.SendMessageAsync("Please choose either Human, Saiyan, or Namekian as your race. `db!register [race]`"); } }
public async Task HandleReady() { try { foreach (IUser user in client.GetGuild(Constants.Guilds.DBZ_EARTH).Users) { if (DBFuncs.PlayerRegistered(user)) { if (DBFuncs.GetAttribute("LOCATION", user) != "null") { DBFuncs.FindDBUser(user).Location = Convert.ToUInt64(DBFuncs.GetAttribute("LOCATION", user)); } } } } catch (Exception e) { Console.WriteLine(e.Message); } }
public async Task HandleCommand(SocketMessage messageParam) { var message = messageParam as SocketUserMessage; if (message == null) { return; } int argPos = 0; if (!Constants.Channels.BLOCKED_CHANNELS.Contains(message.Channel.Id)) { DBUser user = DBFuncs.FindDBUser(message.Author); user.Location = message.Channel.Id; DBFuncs.SetAttribute("LOCATION", message.Author, Convert.ToString(message.Channel.Id)); } //changed prefix to db! because even though bot is called shenron, its more DB in general. if (message.HasStringPrefix("db!", ref argPos)) { if (DBFuncs.PlayerRegistered(message.Author) || message.Content.StartsWith("db!register") || message.Content.StartsWith("db!help")) { var context = new CommandContext(client, message); var result = await commands.ExecuteAsync(context, argPos); if (!result.IsSuccess) { Console.WriteLine(result.ErrorReason); } } else { await message.Channel.SendMessageAsync($"{message.Author.Mention}, you must register with `db!register` before using commands."); } } else { return; } }
public async Task Profile(IUser user) { if (DBFuncs.PlayerRegistered(user)) { var emb = new JEmbed() { ThumbnailUrl = user.GetAvatarUrl(), ColorStripe = Funcs.GetColour(user, Context.Guild) }; emb.Fields.Add(new JEmbedField(x => { x.Header = "Race"; x.Text = DBFuncs.GetAttribute("RACE", user); })); emb.Fields.Add(new JEmbedField(x => { x.Header = "Level"; x.Text = DBFuncs.GetAttribute("LEVEL", user); x.Inline = true; })); emb.Fields.Add(new JEmbedField(x => { x.Header = "EXP"; x.Text = DBFuncs.GetAttribute("EXP", user) + "/" + Convert.ToString(Math.Pow(Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", user)), 2) + 10); x.Inline = true; })); emb.Author.Name = user.Username + "'s Profile"; var embed = emb.Build(); await Context.Channel.SendMessageAsync("", embed : embed); } else { await Context.Channel.SendMessageAsync("Player in not registered"); } }