public static async Task <IUserMessage> EmbedResponseAsync(IUserMessage message, ResponseFormat format = ResponseFormat.Default, string title = "", string description = "", EmbedFooterBuilder footer = null) { return(await message.ReplyAsync( embed : CreateResponseEmbed(format, title, description, footer).Build() )); }
public async void GetActivity(SocketMessage sm) { IUserMessage ium = (IUserMessage)sm; // Grab the in-game names var inGameName = await GetInGameNames(sm); // Get the members list SpreadsheetsResource.ValuesResource.GetRequest memberRequest = _service.Spreadsheets.Values.Get(_spreadsheetId, _members); ValueRange memberResponse = await memberRequest.ExecuteAsync(); IList <IList <Object> > memberValues = memberResponse.Values; // Get the activity list SpreadsheetsResource.ValuesResource.GetRequest activityRequest = _service.Spreadsheets.Values.Get(_spreadsheetId, _activityList); ValueRange activityResponse = await activityRequest.ExecuteAsync(); IList <IList <Object> > activityValues = activityResponse.Values; // Iterate through and find the related values if (activityValues != null && activityValues.Count > 0) { foreach (var ign in inGameName) { var member = activityValues.First(m => m[0].ToString() == ign[0].ToString()); EmbedBuilder eb = new EmbedBuilder { Title = ign[0] + " - " + memberValues.First(m => m[0].ToString() == ign[0].ToString())[3], Description = "Note that each section is capped at 60%, 5%+15% and 20% respectively" }; var score = Double.Parse(member[12].ToString()?.Split('%')[0] !); eb.Color = Math.Abs(score - 100.00) < 0.01 ? new Color(47, 62, 80) : score < 100.00 && score >= 85.00 ? new Color(34, 73, 54) : score <85.00 && score> 50.00 ? new Color(100, 0, 0) : new Color(40, 40, 40); eb.AddField("Galactic Power", member[2]); eb.AddField("Tickets - " + member[4], member[3] + " Missed"); eb.AddField("Territory War - " + member[6] + " + " + member[9], member[5] + " Joined | " + member[7] + " Defense Banners | " + member[8] + " Offense Banners"); eb.AddField("Territory Battle - " + member[11], member[10] + " Participation"); eb.AddField("Overall Score", member[12] + (score < 85.00 ? " - ON PROBATION" : "")); await ium.ReplyAsync(null, false, eb.Build()); } } }
public async Task ChangeRaidRole(DiscordSocketClient dsc, IUserMessage ium) { var guild = dsc.GetGuild(_mutinyGuild); await guild.DownloadUsersAsync(); if (ium.Author is IGuildUser user && user.RoleIds.Contains(_mp2Role)) { if (user.RoleIds.Contains(_mp2Raider)) { await user.RemoveRoleAsync(guild.GetRole(_mp2Raider)); await ium.ReplyAsync("You no longer have the MP2-Raider role"); } else { await user.AddRoleAsync(guild.GetRole(_mp2Raider)); await ium.ReplyAsync("You now have the MP2-Raider role"); } }
/// <summary>Sends a reply to a message in the same channel.</summary> /// <param name="message">The message to reply to.</param> /// <param name="embed">The embed message to send.</param> /// <param name="channelBackup">Optional backup channel if <paramref name="message"/> is null.</param> public static IUserMessage SendReply(IUserMessage message, Embed embed, IMessageChannel channelBackup = null) { if (message != null && message.Id != LastRepliedMessage) { LastRepliedMessage = message.Id; return(message.ReplyAsync(embed: embed, allowedMentions: AllowedMentions.None).Result); } else { return((message?.Channel ?? channelBackup).SendMessageAsync(embed: embed, allowedMentions: AllowedMentions.None).Result); } }
public static async Task <IUserMessage> WelcomeDm(this IUserMessage user, IGuild guild, string msg) { var embed = new EmbedBuilder() .WithColor(new Color(43, 182, 115)) .WithTitle($"**Welcome to {guild.Name}**") .WithDescription(msg) .WithThumbnailUrl(guild.IconUrl) .WithCurrentTimestamp() .Build(); var message = await user.ReplyAsync(embed : embed); return(message); }
private async Task BurnMomentumReactionHandler(IUserMessage message, ISocketMessageChannel channel, SocketReaction reaction, IUser user) { if (!IsPlayerCardPost(message)) { return; } var cs = await ChannelSettings.GetChannelSettingsAsync(channel.Id); var player = new Player().WithChannelSettings(cs).PopulateFromEmbed(message.Embeds.First()); int startingMomentum = player.Momentum; player.Momentum = 2 - player.Debilities; await message.ModifyAsync(msg => msg.Embed = player.GetEmbedBuilder().Build()).ConfigureAwait(false); await message.RemoveReactionAsync(reaction.Emote, user).ConfigureAwait(false); await message.ReplyAsync(String.Format(PlayerResources.BurnMomentumMessage, player.Name, startingMomentum)); }
/// <summary> /// Checks whether the user is trying to get support. /// </summary> /// <param name="s">Current user message.</param> private async Task CheckSupportAsync(SocketMessage s) { if (s.Source == MessageSource.User) { if (s.Channel.GetType() == typeof(SocketDMChannel)) { string msg = s.ToString(); SocketUserMessage message = s as SocketUserMessage; if (msg.ToLower().StartsWith("support ") || msg.ToLower().StartsWith("support") || msg.ToLower().StartsWith($"&support") || msg.ToLower().StartsWith($"&support ")) { msg = Regex.Replace(msg, "support", ""); IUserMessage reply = (IUserMessage)s; EmbedBuilder b = Global.EmbedMessage("Support ticket submitted", "Thank you for submitting your support ticket. A developer will review it shortly.", true, Color.Magenta); b.WithFooter($"Your ticked id is: {s.Id}"); b.WithCurrentTimestamp(); await reply.ReplyAsync("", false, b.Build()); EmbedBuilder eb = new EmbedBuilder(); eb.WithAuthor(s.Author); eb.WithCurrentTimestamp(); eb.WithFooter($"DM channel Id: {s.Channel.Id}\nSupport ticket Id: {s.Id}"); eb.WithTitle("New support ticket"); eb.WithDescription($"```{msg}```"); eb.WithColor(Color.DarkPurple); await _client.GetGuild(Global.SupportGuildId).GetTextChannel(Global.SupportChannelId).SendMessageAsync("", false, eb.Build()); return; } await message.ReplyAsync("Sorry, but commands are not enabled in DM's. Please try using bot commands in a server."); return; } } }
public async void GetAllActivity(IUserMessage ium) { SpreadsheetsResource.ValuesResource.GetRequest activityRequest = _service.Spreadsheets.Values.Get(_spreadsheetId, _activityList); // Prints the names and majors of students in a sample spreadsheet: ValueRange activityResponse = await activityRequest.ExecuteAsync(); IList <IList <Object> > activityValues = activityResponse.Values; if (activityValues != null && activityValues.Count > 0) { EmbedBuilder eb = new EmbedBuilder { Title = "Guild Participation", Color = new Color(255, 255, 0) }; StringBuilder sb = new StringBuilder(); sb.Append("```"); foreach (var member in activityValues.Take(10)) { sb.Append($"{member[0],-20} {"|",0} {member[12],15}\n"); } sb.Append("```"); eb.AddField("================ 1 - 10 ===============", sb); sb = new StringBuilder(); sb.Append("```"); foreach (var member in activityValues.Skip(10).Take(10)) { sb.Append($"{member[0],-20} {"|",0} {member[12],15}\n"); } sb.Append("```"); eb.AddField("================ 11 - 20 ================", sb); sb = new StringBuilder(); sb.Append("```"); foreach (var member in activityValues.Skip(20).Take(10)) { sb.Append($"{member[0],-20} {"|",0} {member[12],15}\n"); } sb.Append("```"); eb.AddField("=============== 21 - 30 ===============", sb); sb = new StringBuilder(); sb.Append("```"); foreach (var member in activityValues.Skip(30).Take(10)) { sb.Append($"{member[0],-20} {"|",0} {member[12],15}\n"); } sb.Append("```"); eb.AddField("=============== 31 - 40 ===============", sb); sb = new StringBuilder(); sb.Append("```"); foreach (var member in activityValues.Skip(40).Take(10)) { sb.Append($"{member[0],-20} {"|",0} {member[12],15}\n"); } sb.Append("```"); eb.AddField("=============== 41 - 50 ===============", sb); await ium.ReplyAsync(null, false, eb.Build()); } else { await ium.ReplyAsync("No Data Found"); } }
protected async Task InlineReply(IUserMessage userMessage, string messageText) => await userMessage.ReplyAsync($"{new Emoji("👉")} {messageText}");