當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Session.ChannelMessageDelete方法代碼示例

本文整理匯總了Golang中github.com/bwmarrin/discordgo.Session.ChannelMessageDelete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.ChannelMessageDelete方法的具體用法?Golang Session.ChannelMessageDelete怎麽用?Golang Session.ChannelMessageDelete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/bwmarrin/discordgo.Session的用法示例。


在下文中一共展示了Session.ChannelMessageDelete方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: messageDelete

func messageDelete(s *discordgo.Session, chanID string, mID string) {
	c := config.Get()
	if !c.KeepTriggers {
		s.ChannelMessageDelete(chanID, mID)
	}
}
開發者ID:Skullever,項目名稱:digo,代碼行數:6,代碼來源:handler.go

示例2: messageCreate

func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
	var deleteMessageAuthor bool
	deleteMessageAuthor = true

	text := m.ContentWithMentionsReplaced()

	if m.Author.ID == s.State.User.ID {
		// Ignore self
		return
	}

	channel, _ := s.State.Channel(m.ChannelID)

	if channel.IsPrivate {
		channel.Name = "direct message"
	}

	if strings.HasPrefix(text, "!") || strings.HasPrefix(text, ".") || strings.HasPrefix(text, "bot.") {
		// Ignore shit meant for other bots
		return
	}

	isMentioned := isUserMentioned(s.State.User, m.Mentions) || m.MentionEveryone

	text = strings.Replace(text, "@everyone", "", -1)

	// Log cleaned up message
	fmt.Printf("%20s %20s %20s > %s\n", channel.Name, time.Now().Format(time.Stamp), m.Author.Username, text)

	if shouldIgnore(m.Author) {
		return
	}

	c := config.Get()

	for _, ChannelID := range c.Channels {
		if m.ChannelID == ChannelID {
			linksFound, reply := lewd.ParseLinks(text)

			if linksFound {
				content := strings.Join(lewd.ContentLinks(m.Content)[:], " ")
				if deleteMessageAuthor {
					s.ChannelMessageDelete(m.ChannelID, m.ID)
				}
				s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%s: %s\n%s", m.Author.Username, content, reply))
				return
			}
		}
	}

	// Accept the legacy mention as well and trim it off from text
	if strings.HasPrefix(strings.ToLower(text), "lewdbot, ") {
		text = text[9:]
		isMentioned = true
	}

	if channel.IsPrivate || isMentioned {
		var reply string
		reply = regex.Lewdbot.ReplaceAllString(reply, m.Author.Username)

		// Log our reply
		fmt.Printf("%20s %20s %20s > %s\n", channel.Name, time.Now().Format(time.Stamp), s.State.User.Username, reply)

		s.ChannelMessageSend(m.ChannelID, reply)
	}
}
開發者ID:Xwth,項目名稱:h-bot,代碼行數:66,代碼來源:main.go

示例3: checkLink

func checkLink(s *discordgo.Session, m string, chanID string, mID string) {
	if strings.Contains(strings.ToLower(m), "www.facebook") {
		s.ChannelMessageDelete(chanID, mID)
	}
}
開發者ID:Muckfoot,項目名稱:Go,代碼行數:5,代碼來源:basic_bot.go


注:本文中的github.com/bwmarrin/discordgo.Session.ChannelMessageDelete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。