public async Task Github(string branch = "") { var embed = new Discord.EmbedBuilder(); string Branch = branch.ToLower(); //embed.WithTitle("Github"); if (Branch == "master") { embed.AddInlineField("Master", "https://github.com/Gagong/Toshinou-Revamped/tree/master"); } else if (Branch == "beta") { embed.AddInlineField("Beta", "https://github.com/Gagong/Toshinou-Revamped/tree/beta").WithFooter("WARNING: This is not a stable build, recommended to use Master"); } else { embed.AddInlineField("Master (Recommended)", "https://github.com/Gagong/Toshinou-Revamped/tree/master"); embed.AddInlineField("Beta", "https://github.com/Gagong/Toshinou-Revamped/tree/beta"); } embed.Color = Color.Green; embed.WithAuthor("Smart Toshinou | Github", "", ""); // Name, IconURL, URL(???) await ReplyAsync("", false, embed); }
public async Task Help() { var embed = new Discord.EmbedBuilder(); embed.AddField("!help", "Will display list of commands!"); embed.AddField("!info", "Will display Smart Toshinou info!"); embed.AddField("!checkUpdate", "Will display the status of the bot!"); embed.AddField("!github", "Will link the Github!"); embed.AddField("!github master", "Stable Toshinou version!"); embed.AddField("!github beta", "Beta Toshinou version!"); embed.AddField("!roll <amount>", "Will roll a number between 1 and <amount>!"); embed.Color = Color.Green; embed.WithAuthor("Smart Toshinou | Help", "", ""); // Name, IconURL, URL(???) await ReplyAsync("", false, embed); }
// public static Embed CurrentUserEmbed(ICommandContext Context) // { // Mock database = DatabaseManager.GetMock(); // DiscordUser atlasAccount = null; // try // { // atlasAccount = // database.Users.FirstOrDefault(x => (x as DiscordUser).Discordid == (long)Context.User.Id); // // } // catch // { // //Log user not registed // } // Discord.EmbedBuilder eb = BaseBuilder("", "", ColorPicker.UserModule, // new EmbedAuthorBuilder().WithName("Information about " + Context.User.Username), // Context.User.GetAvatarUrl()); // if (atlasAccount != null) // { // eb.Description = "Displaying user information for the " + Names.Systemname + " account"; // eb.AddField(new EmbedFieldBuilder().WithName(Names.Systemname + " Information").WithValue( // "**Name:** " + atlasAccount.Name + "\n"+ // "**Account created:** " + atlasAccount.CreationDate.ToLongDateString())); // } // else // { // eb.AddField(new EmbedFieldBuilder() // .WithValue("User is not registed, use -user register to register now.") // .WithName(Names.Systemname + " Account")); // } // //eb.WithUrl("http://placeholder.com/user/id/111020301023"); // string discordInformation = ""; // try // { // var user = Context.User as IGuildUser; // discordInformation += "**Joined at: **" + user.JoinedAt.Value.Date.ToLongDateString() + "\n"; // } // catch // { // //Log User not in guild // } // discordInformation += "**Status:** " + Context.User.Status + "\n"; // // if (Context.User.Game != null) // { // discordInformation += "**Currently Playing: **" + Context.User.Game.Value.Name + "\n"; // } // eb.AddField(new EmbedFieldBuilder().WithName("Discord information").WithValue(discordInformation)); // //if (atlasAccount != null) // //{ // // if (atlasAccount.Summoners.Count > 0) // // { // // string summoners = ""; // // foreach (var summoner in atlasAccount.Summoners) // // { // // summoners += summoner.Region + ": " + summoner.SummonerId; //TODO Make this a Tier // // } // // eb.AddField(new EmbedFieldBuilder().WithName("Summoner Information").WithValue(summoners)); // // } // // else // // { // // eb.AddField(new EmbedFieldBuilder().WithName("Summoner Information") // // .WithValue("This user has no summoners.")); // // } // //} // if (atlasAccount != null) // { // string accountinfo = "User does not have accounts linked\nUser **-HELPCOMMAND** to get started."; // if (atlasAccount.SmashAccount.Username != null && (bool)atlasAccount.SmashAccount.IsVerified) // { // accountinfo = "**" + Names.SmashLadder + " account:**\n" + atlasAccount.SmashAccount.Username + " "+ // atlasAccount.SmashAccount.Rank; // } // eb.AddField("Accounts", accountinfo); // } // // return eb.Build(); // } // public static Embed CurrentServerEmbed(IGuild guild) // { // DiscordServer server; // var database = DatabaseManager.GetMock(); // try // { // server = database.Servers.FirstOrDefault(x => x.ServerId == guild.Id); // } // catch // { // server = null; // } // // Discord.EmbedBuilder builder = BaseBuilder("", "Information about this server known to " + Names.BotName, ColorPicker.ServerModule, new EmbedAuthorBuilder().WithName(guild.Name), guild.IconUrl); // builder.AddField(new EmbedFieldBuilder().WithName("Discord Information") // .WithValue("**Name:** " + guild.Name + "\n" // + "**Users:** " + (guild as SocketGuild).Users.Count + "\n" // + "**Created at:** " + guild.CreatedAt.DateTime.ToLongDateString() + "\n" // + "**Owner:** " + guild.GetOwnerAsync().Result.Username)); // if (server == null) // { // builder.AddField(new EmbedFieldBuilder().WithName(Names.Systemname + " Information") // .WithValue( // "Server is not linked to an account. Let the owner use -server register *<Tier>* to start")); // } // else // { // builder.AddField(new EmbedFieldBuilder().WithName(Names.Systemname + " Information").WithValue( // "**Name: **" + server.Name+"\n"+ // "**Description: **"+ server.Description+"\n"+ // "**Joined at: **" + server.JoinDateTime.ToLongDateString()+"\n"+ // "**Votes: **" + server.Votes)); // } // return builder.Build(); // } // // public static Embed ServerList(string filter) // { // Discord.EmbedBuilder builder = BaseBuilder("", "All servers known ordered by votes.", ColorPicker.ServerModule, new EmbedAuthorBuilder().WithName(Names.Systemname + " server list"), null); // if (string.IsNullOrEmpty(filter)) //No parameter is given and we should display the full server list // { // List<DiscordServer> servers = DatabaseManager.GetMock().Servers.ToList(); // //Add servers from other sources // var orderedServers = servers.OrderBy(x => x.Votes).ToList(); // int maxservers = 5; //Maximal servers to display // if (maxservers > orderedServers.Count()) maxservers = orderedServers.Count; // // for (int i = 0; i < maxservers; i++) // { // // builder.AddField(new EmbedFieldBuilder().WithName(orderedServers[i].Name) // .WithValue("**Votes:** " + orderedServers[i].Votes + "\n" + // "**Description: **" + orderedServers[i].Description)); // } // } // return builder.Build(); // } //Base Builder public static Discord.EmbedBuilder BaseBuilder(string title, string description, Color color, EmbedAuthorBuilder authorBuilder, string thumbnailurl) { Discord.EmbedBuilder builder = new Discord.EmbedBuilder().WithColor(color).WithFooter(Names.BotName).WithCurrentTimestamp(); if (!string.IsNullOrEmpty(description)) { builder.WithDescription(description); } if (!string.IsNullOrEmpty(title)) { builder.WithTitle(title); } if (authorBuilder != null) { builder.WithAuthor(authorBuilder); } if (!string.IsNullOrEmpty(thumbnailurl)) { builder.WithThumbnailUrl(thumbnailurl); } return(builder); }
public static Discord.EmbedBuilder UserInfo(string username) { RootObject root = RequestHandler.GetUserByName(username); User user = root.user; Discord.EmbedBuilder builder = Builders.BaseBuilder("Link to " + Names.SmashLadder + " Profile", "All information known about **" + user.username + "**", ColorPicker.SmashModule, new EmbedAuthorBuilder().WithName(Names.SmashLadder) .WithUrl("http://www.smashladder.com"), ""); builder.WithThumbnailUrl("https://www.smashladder.com/images/subhypepikachu-logo.png"); if (user.selected_flair != null) { builder.WithAuthor(new EmbedAuthorBuilder().WithName(Names.SmashLadder) .WithUrl("http://www.smashladder.com").WithIconUrl("http:" + user.selected_flair.url)); } string location = ""; if (!string.IsNullOrEmpty(user.location.Locality)) { location += user.location.Locality + ", "; } if (!string.IsNullOrEmpty(user.location.State)) { location += user.location.State + ", "; } if (!string.IsNullOrEmpty(user.location.Country.name)) { location += user.location.Country.name; } string status = "Offline"; string sub = ""; if (user.is_online != null) { status = "Online"; } if (user.is_subscribed != null) { sub = "**User is subscribed!**\n"; } builder.AddField(new EmbedFieldBuilder().WithName("Profile").WithValue( "**Name: **" + user.username + "\n" + "**Member Since: **" + user.member_since.full.ToLongDateString() + "\n" + "**Location: **" + location + "\n" + "**Status message: **" + user.away_message + "\n" + "**Total matches played: **" + user.total_matches_played + "\n" + "**Status: **" + status + "\n" + sub )); var filteredgames = user.ladder_information.AllGames.Where(x => x != null).ToList(); try { filteredgames = filteredgames.Where(x => x.league.stats.RankedPlayed != 0).ToList(); } catch { //No ranked games played } foreach (var game in filteredgames) { try { var characters = ""; var count = 3; if (game.characters.Count < count) { count = game.characters.Count; } if (count != 0) { characters = "**Characters:**\n"; for (int i = 0; i < count; i++) { characters += "** " + game.characters[i].name + ": **" + game.characters[i].percent + "%\n"; } } var rank = "**Ranked: **Unranked\n"; if (!string.IsNullOrEmpty(game.league.Tier)) { rank = "**Ranked: **" + game.league.Tier + " " + game.league.Division + "\n"; } builder.AddField(new EmbedFieldBuilder().WithName(game.name).WithValue( "**Total ranked games played: **" + game.league.stats.RankedPlayed + "\n" + rank + characters )); } catch { } } if (root.now_playing != null) { string type = "Friendlies"; if (root.now_playing.is_ranked) { type = "Ranked"; } string rankp1 = "Unranked"; try { var games1 = root.now_playing.player1.ladder_information.AllGames; games1 = games1.Where(x => x != null).ToList(); SmashHandler.DataTypes.Game gamep1 = games1.Single(x => x.id == root.now_playing.ladder.id); if (!string.IsNullOrEmpty(gamep1.league.Tier)) { rankp1 = gamep1.league.Tier + " " + gamep1.league.Division; } } catch { } string rankp2 = "Unranked"; try { var games2 = root.now_playing.player2.ladder_information.AllGames; games2 = games2.Where(x => x != null).ToList(); SmashHandler.DataTypes.Game gamep2 = games2.Single(x => x.id == root.now_playing.ladder.id); if (!string.IsNullOrEmpty(gamep2.league.Tier)) { rankp2 = gamep2.league.Tier + " " + gamep2.league.Division; } } catch { } builder.AddField(new EmbedFieldBuilder().WithName("Currently Playing").WithValue( "**" + root.now_playing.ladder_name + " " + type + "**: \n" + "Using " + root.now_playing.preferred_build.name + "\n" + root.now_playing.player1.username + " " + "(" + rankp1 + ")" + " vs " + root.now_playing.player2.username + " (" + rankp2 + ")")); } builder.WithUrl(user.profile_url); return(builder); }
/// <summary> Fills the embed author field with the provided user's full username and avatar URL. </summary> public static EmbedBuilder WithAuthor(this EmbedBuilder builder, IUser user) => builder.WithAuthor($"{user.Username}#{user.Discriminator}", user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl());