question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Direct messages are not sent

See original GitHub issue

I need to send a message to all guild participants I have a message handler:

var userId = socketMessage.Author.Id;
var mainGuild = _client.GetGuild(Bot.MainGuildId);

// Send news
if (socketMessage.Channel.Id == NewsChannelId)
{    
    var users = mainGuild.GetUsersAsync().GetAsyncEnumerator();
    
    while (users.MoveNextAsync().Result)
    {
        Console.WriteLine(users.Current.Count);
        
        foreach (var user in users.Current)
        {
            try
            {
                var channel = await user.GetOrCreateDMChannelAsync();
                await channel.SendMessageAsync(socketMessage.Content);
            
                Console.WriteLine($"Sent msg to {user.Username}");
            }
            catch (Discord.Net.HttpException e)
            { 
                Console.Write($"Msg: {e.Message}\n" +
                            $"Username: {user.Username}");
            }   
        }
    }
}

But while sending a message to the user ( users.MoveNextAsync() ), an HttpException is thrown with the message “Missing Access”. This is probably due to the fact that there is no DIRECT_MESSAGES intent in the config, but if I connect it, the bot will process Ready for a very long time and after that it will not respond to anything.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
LedgendODSTcommented, Dec 12, 2021

That’s called mass dming that’s not allowed

0reactions
Sasino97commented, Jan 16, 2022

I’ve tried mass DMing, not worth it, you’ll just get your Discord application banned. If you’re gonna do it anyway, then add a 10-minute delay every 10 users DMed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix 'Instagram Direct Messages Not Sending' Issue
How to Fix 'Instagram Direct Messages Not Sending' Issue: A Comprehensive Guide · 1. Check Your Internet Connection · 2. Update the Instagram...
Read more >
A Full Guide to Fixing Instagram Messages Not Sending ...
Fix 3: Restart Your Phone ... Restarting your device is the easiest way to fix the Instagram messages sending issue. That often works...
Read more >
Instagram Messages Not Sending? Fix the Problem [The Best ...
Another reason is that the recipient is not following you and has set its settings to receive DMs only from followers. Indeed, that's...
Read more >
Instagram Messages Not Sending? 7 Fixes to Try
1. Make Sure Your Internet Is Working · 2. Check if Instagram Is Down · 3. Fix Instagram's Message Problems by Clearing the...
Read more >
Twitter Direct Message FAQ – DMs
If you are sending Direct Messages to accounts that do not follow you, you may need to verify your phone number. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found