Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageCreate.Content is empty #961

Closed
Vadmeme opened this issue Jun 28, 2021 · 10 comments
Closed

MessageCreate.Content is empty #961

Vadmeme opened this issue Jun 28, 2021 · 10 comments

Comments

@Vadmeme
Copy link

Vadmeme commented Jun 28, 2021

dg, err := discordgo.New("redacted")
if err != nil {
    fmt.Println("error creating Discord session,", err)
    return
}

dg.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
    log.Printf("what: %s", m.Content)
})

err = dg.Open()
if err != nil {
    fmt.Println("error opening connection,", err)
    return
}

// Wait here until CTRL-C or other term signal is received.
fmt.Println("Bot is now running.  Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc

on a discord user token (not a bot, and yes i know this is against discord TOS)
discordgo has the events .content be empty, everything else appears to be there (author, guild, channelid, etc) but the message content is missing

it however is NOT missing if the author is from your active account

EXPECTED BEHAVIOR: outputs what: [message content]
ACTUAL BEHAVIOR:
image

@justindh
Copy link

able to confirm the same on both 22.0 and 23.2

@justindh
Copy link

justindh commented Jun 30, 2021

This is a change on Discords side, not entirely sure what it is, but it only impacts Self bots (fixed by adding bot to your token) an example work around is to use the ChannelMessages to lookup the message like so..

`

func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {

	if m.Content == "" {
		chanMsgs, err := s.ChannelMessages(m.ChannelID, 1, "", "", m.ID)
		if err != nil {
			log.Errorf("unable to get messages: %s", err)
			return
		}
		m.Content = chanMsgs[0].Content
		m.Attachments = chanMsgs[0].Attachments
	}
}

`

@git-shochann
Copy link

Has this problem been resolved?

@justindh
Copy link

Not that I know of, because it is a problem with an unsupported mode, I doubt it will ever get traction

@Tumbler
Copy link

Tumbler commented Dec 9, 2022

I'm having the same issue, but I'm not running a selfbot. And the workaround also doesn't have the content either. I'm at a bit of a loss here...

@Nv7-GitHub
Copy link
Contributor

Make sure to enable the message intent in the developer dashboard

@Tumbler
Copy link

Tumbler commented Dec 12, 2022

You are correct, that was my issue. I should have updated this. Thank you for responding!

@pyrgasm
Copy link

pyrgasm commented Dec 15, 2022

Guys please put somewhere with big text that you have to enable it i went through few tutorials none showed that

@syntaqx
Copy link

syntaqx commented May 26, 2023

For those that run into this, be sure to visit the "Bot" tab under your Application, and
image

@dev-diver
Copy link

@syntaqx solved! thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants