Denis Alexeev
Denis Alexeev

Reputation: 105

How to make a bot react to its own message in discord.net?

The bot sends a message "Do u like or dislike smth" and reacts :thumb-up: and :thumb-down:, then calculates how many people voted for each option. How can I do it? This is my code for now:

    public Task Respects(SocketGuildUser user)
    {
        var emoji = new Emoji("👍");
        Context.Channel.SendMessageAsync($"What do u think about {user.Mention}'s message?");
        return Context.Message.AddReactionAsync(emoji);
    }

And I don't completely understand how to add emoji reaction by text indificator (:thumb_up:).

Upvotes: 2

Views: 2911

Answers (1)

Denis Alexeev
Denis Alexeev

Reputation: 105

I found the answer myself, there is my code:

    [Command("respects"), Alias("F")]  
    [RequireBotPermission(GuildPermission.AddReactions)]
    public async Task Respects(SocketGuildUser user)
    {
        var emoji = new Emoji("\uD83C\uDDEB");
        string message = $"Press F to pay respects to {user.Mention}:";
        var sent = await Context.Channel.SendMessageAsync(message);
        await sent.AddReactionAsync(emoji);
    }

Upvotes: 4

Related Questions