private void ReactionAdded(DSharpPlus.EventArgs.MessageReactionAddEventArgs obj) { if (obj.Emoji.GetDiscordName() == Emojies.SUB) { AddUserToSubs(obj.User); } else if (obj.Emoji.GetDiscordName() == Emojies.UNSUB) { RemoveUserFromSubs(obj.User); } }
private async Task Client_MessageReactionAdded(DSharpPlus.EventArgs.MessageReactionAddEventArgs e) { using var context = new DiscordContext(); using var sankakuContext = new SankakuModel.SankakuContext(); var message = await context.SankakuPost.FirstOrDefaultAsync(post => post.MessageId == Convert.ToInt64(e.Message.Id)); if (message != null) { SankakuModel.ImageVote vote = null; vote = new SankakuModel.ImageVote() { ImageId = message.ImageId, UserId = Convert.ToInt64(e.User.Id), VoteValue = 0 }; string discordName = e.Emoji.GetDiscordName(); if (Config.Emojis.Confirms.Contains(discordName)) { vote.VoteValue = 1; } else if (Config.Emojis.Love.Contains(discordName)) { vote.VoteValue = 3; } else if (Config.Emojis.Declines.Contains(discordName)) { vote.VoteValue = -1; } else if (Config.Emojis.Hate.Contains(discordName)) { vote.VoteValue = -3; } else if (discordName == Config.Emojis.Underage) { await e.Message.DeleteAsync("Underage"); await e.Message.RespondAsync("Oopsie"); } if (vote.VoteValue != 0) { await sankakuContext.ImageVote.AddAsync(vote); } await sankakuContext.SaveChangesAsync(); } }
public static async Task Client_MessageReactionAdded(DSharpPlus.EventArgs.MessageReactionAddEventArgs e) { var messageOwner = MessageOwners.FirstOrDefault(x => x.User == e.User && x.Message == e.Message); if (messageOwner != null) { var board = messageOwner.Gameboard; if (e.Emoji == ReGenerateEmoji) { board.Generate(); await e.Message.ModifyAsync(board.ToDiscordMessage()); } else if (e.Emoji == RevealEmoji) { await e.Message.ModifyAsync(board.ToDiscordMessage(false)); } await e.Message.DeleteReactionAsync(e.Emoji, e.User); e.Handled = true; } }
private async Task OnReactionAdded(DSharpPlus.EventArgs.MessageReactionAddEventArgs e) { try { var guild = e.Channel.Guild; if (await RoleMap.IsMessageMapped(guild, e.Message)) { //Get the mapping DiscordRole role = await RoleMap.GetMapping(guild, e.Emoji); if (role != null) { var member = await guild.GetMemberAsync(e.User.Id); await guild.GrantRoleAsync(member, role, "Response to reaction"); } } }catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
private async Task VoteSkipUpdate(DSharpPlus.DiscordClient client, DSharpPlus.EventArgs.MessageReactionAddEventArgs messageReactionAdd) { var voteSkipMessage = ShimakazeBot.playlists[messageReactionAdd.Guild]?.voteSkip?.message; if (voteSkipMessage == messageReactionAdd.Message) { var lvc = ShimakazeBot.lvn?.GetGuildConnection(messageReactionAdd.Guild); if (lvc != null) { var reactionEmote = DiscordEmoji.FromName(ShimakazeBot.Client, $":{ShimaConsts.VoteSkipEmote}:"); if (ShimakazeBot.playlists[messageReactionAdd.Guild] .voteSkip.requester.Id != messageReactionAdd.User.Id && lvc.Channel.Users.FirstOrDefault(member => member.Id == messageReactionAdd.User.Id) != null && messageReactionAdd.Emoji == reactionEmote) { if (messageReactionAdd.Message.Reactions.FirstOrDefault(reaction => reaction.Emoji == reactionEmote) .Count >= Math.Ceiling(lvc.Channel.Users.Count() / 2.0)) { await SkipSong(messageReactionAdd.Guild, messageReactionAdd.Channel, lvc, true); } } else { await messageReactionAdd.Message.DeleteReactionAsync( messageReactionAdd.Emoji, messageReactionAdd.User); } } } }
public static Task Client_MessageReactionAdded(DiscordClient sender, DSharpPlus.EventArgs.MessageReactionAddEventArgs e) { return(Task.CompletedTask); }
private Task Discord_MessageReactionAdded(DiscordClient sender, DSharpPlus.EventArgs.MessageReactionAddEventArgs e) { return(RoleManager.CheckReactionAddedAsync(e)); }