【发布时间】:2019-07-14 07:13:55
【问题描述】:
我正在使用 Discord.Net 库在 C# 中编写一个 Discord 机器人。我有一个工作机器人,它会扫描消息并删除包含文本“gif”“giphy”等的消息。这会删除 Discord 自动嵌入的所有 gif 链接。但是,没有检测到直接上传的 .gif 文件。
我想要一种方法,当文件上传到 Discord 文本频道时,接收该文件的类型,最好是字符串格式,如“txt”或“png”等。
【问题讨论】:
-
您是否检查了 Attachment#Url 属性?
-
@Still 我该怎么做呢?我尝试过使用 Context.Message.Attachments、Message.Attatchments 和 MessageParam.Attatchments,但无论我发布文本消息、图像或其他文件,它总是返回相同的内容:
System.Collections.Immutable.ImmutableArray'1[Discord.Attachment]Where Context =new SocketCommandContext(Client, Message);和消息 =MessageParam as SocketUserMessage; -
因为它是一个集合;你不 ToString 一个集合。
标签: c# discord discord.net