Discord.net是否可以通过编程方式添加自定义服务器表情符号反应?

时间:2019-11-13 20:23:51

标签: c#-3.0 discord discord.net

我想知道是否有一种方法可以添加属于我们服务器的自定义非标准表情符号。

例如,这起作用

var context = new SocketCommandContext(_client, message as SocketUserMessage);
await context.Message.AddReactionAsync(new Emoji("?")).ConfigureAwait(false);

但这不起作用

var context = new SocketCommandContext(_client, message as SocketUserMessage);
await context.Message.AddReactionAsync(new Emoji(":MyCustomEmoji:")).ConfigureAwait(false);

问题

是否可以添加用于服务器的自定义表情符号?如果是这样,请解释。

1 个答案:

答案 0 :(得分:1)

非标准表情符号由Emote Class管理。这是link to the additional documentation

  

这直接来自上面链接的Emote类的文档

public async Task SendAndReactAsync(ISocketMessageChannel channel)
{
    var message = await channel.SendMessageAsync("I am a message.");

    // Creates a Unicode-based emoji based on the Unicode string.
    // This is effectively the same as new Emoji("?").
    var heartEmoji = new Emoji("\U0001f495");
    // Reacts to the message with the Emoji.
    await message.AddReactionAsync(heartEmoji);

    // Parses a custom emote based on the provided Discord emote format.
    // Please note that this does not guarantee the existence of
    // the emote.
    var emote = Emote.Parse("<:thonkang:282745590985523200>");
    // Reacts to the message with the Emote.
    await message.AddReactionAsync(emote);
}
  

有效的Emote格式为<:emoteName:emoteId>。这可以通过使用Discord聊天客户端在表情符前使用\进行转义来获得。