【问题标题】:Send message to Discord server based on input to text boxes?根据文本框的输入向 Discord 服务器发送消息?
【发布时间】:2019-03-10 09:15:09
【问题描述】:

我正在尝试在 Visual Studio 中使用 C# 制作应用程序。我需要一些帮助,我想提交这样的模板:

<discord tag>
Link: <link>
Description: <desc>

任何帮助都是有用的!谢谢!

【问题讨论】:

  • NuGet 上有一个 Discord.Net 包,可以帮助使用 API。这就是你需要帮助的具体情况吗?从你的问题看不清楚。而且我不明白你的模板:这里的标签是什么,#channel 名称或用户名,还是别的什么?链接和说明是什么?你打算用这些来组装消息体吗?

标签: c# discord


【解决方案1】:

假设你想给一篇文章的链接发送消息:

public class Article
{
    public string Link { get; set; }
    public string Description { get; set; }
}

那就试试吧:

// implement your required logic for getting the tag
string tag = GetTag();

// implement your required logic for getting the reference
Article article = GetLinkWithDescription();

// Prepare the message
string message = string.Join(
   "\n", 
   $"<@{tag}>", 
   $"Link: {article.Link}", 
   $"Description: {article.Description}"
); 

// send the message
await Context.Channel.SendMessageAsync(message);

【讨论】:

    猜你喜欢
    • 2020-10-26
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 2021-03-24
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    相关资源
    最近更新 更多