Discord.Net 2.0将消息发送到特定频道

时间:2020-10-12 08:13:32

标签: vb.net discord.net

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

这是我的kick命令,如何使它将嵌入内容发送到特定频道?我已经设置好了,因此它向用户发送了嵌入,但现在我希望它可以将嵌入发送到服务器中的某个通道。也是一个旁注。有人知道我可以在哪里将其托管在网上,而不是自我托管或如何托管该机器人的好教程吗?

1 个答案:

答案 0 :(得分:0)

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