如何创建具有不和谐的通道

我想让一个机器人在不和谐上创建一个频道。


我已经与不和谐令牌建立了联系:


// Create a new Discord session using the provided bot token.

dg, err := discordgo.New("Bot " + Token)

if err != nil {

    fmt.Println("error creating Discord session,", err)

    return

}


// Register the channelCreate func as a callback for ChannelCreate events.

dg.AddHandler(channelCreate)


// Open a websocket connection to Discord and begin listening.

err = dg.Open()

if err != nil {

    fmt.Println("error opening connection,", err)

    return

 }

}


// channel is create

func channelCreate(s *discordgo.Session, event *discordgo.ChannelCreate ) {


     // create channel here

}

如何在 https://gowalker.org/github.com/jonas747/discordgo#ChannelCreate 上使用 ChannelCreate 类型


杨__羊羊
浏览 207回答 1
1回答

POPMUISE

discordgo.MessageCreate是频道创建的事件。这意味着处理程序将在创建通道时触发。我不确定你希望机器人创建通道的条件是什么。假设你想要通过向机器人发送消息来创建通道。首先需要在消息事件上添加处理程序func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {     // Ignore all messages created by the bot itself     if m.Author.ID == s.State.User.ID {        return     }    if m.Content == "create channel" {         s.GuildChannelCreate(guildID, name, type)     } }类型为下列之一:// Block contains known ChannelType valuesconst (     ChannelTypeGuildText ChannelType = iota     ChannelTypeDM     ChannelTypeGuildVoice     ChannelTypeGroupDM     ChannelTypeGuildCategory     ChannelTypeGuildNews     ChannelTypeGuildStore )
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go