Discord.net 无法启动 RequestOptions

Discord.net cannot initiate RequestOptions

您好,我一直在尝试在 Discord.net 中开发一个机器人,到目前为止效果很好。 虽然我遇到的问题是我正在尝试使用一个选项从 ITextChannel 使用 GetMessagesAsync。 不幸的是,我不知道如何启动 RequestOptions,我尝试搜索 the documentation 但一无所获。

    private ulong SearchMessageByMessageLink(ulong messageId, ITextChannel channel)
        {
            var messageList = GetMessagesAsync(100, channel,options:[{around:messageId}]);//fix
            return 1;
        }

    public IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong id, ITextChannel channel,  RequestOptions options)
        {
            CacheMode mode = CacheMode.AllowDownload;
            IAsyncEnumerable<IReadOnlyCollection<IMessage>> messageList = channel.GetMessagesAsync(100, mode, options);
            return messageList;
        }

我想知道 Discord.net 是否可以使用 around:messageId 雪花功能。

我从来不需要使用 RequestOptions,而且我不确定它的作用。此操作不需要它。

Discord.NET支持获取After和Before消息,但是目前Around还没有实现,会抛出NotImplementedException。

要使用 Before 或 After,您可以使用 overload for GetMessagesAsync which contains a Direction 参数。如果你需要 Around 那么我建议提出两个请求。一张在之前,一张在之后。

这是一个例子:

await channel.GetMessagesAsync(afterMessage.Id, Direction.After, count).FlattenAsync()