public static Embed ConstructEmbed(Event evt, out string memberString) { SocketGuildUser user = Utility.GetServer().GetUser(evt.hostID); memberString = "Calling"; foreach (ulong id in evt.eventMemberIDs) { memberString += " <@" + id + ">"; } memberString += "!"; EmbedBuilder builder = new EmbedBuilder() .WithTitle("Event announcement for " + evt.name + "!") .WithDescription(evt.description) .WithColor(CSetColor.GetUserColor(evt.hostID).Color) .WithTimestamp(evt.time) .WithThumbnailUrl(Uri.IsWellFormedUriString(evt.iconUrl, UriKind.Absolute) ? evt.iconUrl : "") .AddField("Duration", evt.duration.ToString()) .WithAuthor(author => { author .WithName(Utility.GetUserName(user)) .WithIconUrl(user.GetAvatarUrl()); }); Embed embed = builder.Build(); return(embed); }
public Embed GetHelpEmbed(SocketMessage e, bool advanced) { EmbedBuilder builder = new EmbedBuilder(); if (!commandEnabled) { builder.WithTitle("Not enabled on this server."); return(builder.Build()); } builder.WithAuthor(Utility.GetUserName(Utility.GetServer().GetUser(Program.discordClient.CurrentUser.Id)) + " Command Help") // lolwhat. .WithTitle($"Command \"{helpPrefix}{command}\"") .WithDescription(shortHelp); // This is quite similar to GetArgs and GetHelp together, and the other functions are obsolete due to this. MethodInfo [] methods = GetType().GetMethods().Where(x => x.Name == "Execute").ToArray(); for (int i = 0; i < methods.Length; i++) { if (overloads.Count <= i) { builder.AddField("Undefined overload", "Blame that lazy bastard of a dev."); } else { MethodInfo info = methods [i]; Overload ol = overloads [i]; var parameters = GetDescriptiveOverloadParameters(i); string olText = advanced ? $"{parameters.returnType} => " : helpPrefix + command; olText += " ("; for (int j = 1; j < parameters.types.Length; j++) // Remember to ignore first parameter, it being the SocketUserMessage. { Type type = parameters.types[j]; string name = parameters.names [j]; olText += advanced ? type.Name + " " + name : name; if (j != parameters.types.Length - 1) { olText += "; "; } } olText += ")"; builder.AddField(olText, ol.description); } } string footer = string.Empty; if (isAdminOnly) { footer += " - ADMIN ONLY"; } if (allowInMain) { footer += " - ALLOWED IN MAIN"; } if (availableInDM && !availableOnServer) { footer += " - ONLY IN DM"; } if (availableInDM && availableOnServer) { footer += " - AVAILABLE IN DM"; } if (requiredPermission != Permissions.Type.Null) { footer += " - REQUIRIES PERMISSION: " + requiredPermission.ToString().ToUpper(); } builder.WithColor(CSetColor.GetUserColor(Program.discordClient.CurrentUser.Id).Color); builder.WithFooter(footer); return(builder.Build()); }