vb.net - Discord.Net 2.0 向特定频道发送消息
问题描述
Public Async Function Kick(ByVal user As IGuildUser, <Remainder> ByVal reason As String) As Task
Dim guild = Context.Guild
Dim bot = Context.Client
Dim message = Context.Message
Dim u = Context.User
'Channel Info
Dim _client As New DiscordSocketClient
Dim id As ULong = 1235234987 'Random numbers not a channel id
Dim chnl As IMessageChannel = _client.GetChannel(id)
If u.Id = "id" Or "id" Or "id" Then
Dim embed As New EmbedBuilder With {
.Author = New EmbedAuthorBuilder With {
.IconUrl = u.GetAvatarUrl,
.Name = u.Username
},
.Title = $"{user.Username}#{user.Discriminator}'s Kick Information",
.ImageUrl = "https://i.imgur.com/vc241Ku.jpeg",
.Description = reason,
.Color = New Color(masterClass.randomEmbedColor),
.ThumbnailUrl = user.GetAvatarUrl,
.Timestamp = Context.Message.Timestamp,
.Footer = New EmbedFooterBuilder With {
.Text = "Kick Data",
.IconUrl = guild.IconUrl
}
}
Await chnl.SendMessageAsync("", False, embed.Build())
Await user.SendMessageAsync("", False, embed.Build())
Await user.KickAsync(reason)
Else
Await Context.Channel.SendMessageAsync("You do not match the IDs that are required for this. Bye.")
End If
End Function
这是我的踢命令,我将如何制作它以便将嵌入发送到特定频道?我已经设置了它,所以它会向用户发送嵌入,但我希望它现在将该嵌入发送到服务器中的某个通道。也是一个旁注。有谁知道我可以在哪里在线托管机器人而不是自我托管或关于我可以在哪里托管它的好教程?
解决方案
Public Async Function Kick(ByVal user As IGuildUser, <Remainder> ByVal reason As String) As Task
Dim guild = Context.Guild
Dim chnl = guild.GetTextChannel(123456789)
Dim embed As New EmbedBuilder With {
.Author = New EmbedAuthorBuilder With {
.IconUrl = user.GetAvatarUrl,
.Name = user.Username
},
.Title = $"{user.toString()}'s Kick Information",
.ImageUrl = "https://i.imgur.com/vc241Ku.jpeg",
.Description = reason,
.Color = New Color(masterClass.randomEmbedColor),
.ThumbnailUrl = user.GetAvatarUrl,
.Timestamp = Context.Message.Timestamp,
.Footer = New EmbedFooterBuilder With {
.Text = "Kick Data",
.IconUrl = guild.IconUrl
}
}
Await chnl.SendMessageAsync("", False, embed.Build())
Await user.SendMessageAsync("", False, embed.Build())
Await user.KickAsync(reason)
End Function
推荐阅读
- reactjs - react-styleguidist 中的动态示例
- c# - 问:是否可以将日期时间字段作为 asp.net-mvc-core 中表的键?
- c++ - 如何为全局函数编写单元测试,它在 C++ 中使用 gtest/gmock 调用另一个全局函数?
- android - 我从 firebase 数据库中获得了多次相同的数据,我只需要从 firebase 数据库中获得一次
- reactjs - RN 在 0.57.3 中禁用了样式道具检查吗?
- mysql - 按日期时间范围分组 - MySql
- ios - 有没有办法播种 Swift 4.2 随机数生成器
- ruby-on-rails - 在 Rails 引擎上导入引导程序
- python - 修复来自 API 的 JSON 输出
- docker - Heroku-cli:尝试部署 NodeJS 应用程序的 docker 映像后,docker run 以 127 退出