I want to start off with saying this is a small server between me and my friends, and all of us have consented to the use of something like this, therefore I don't think it breaks any discord guidelines.
I first wrote some test code to test the bot being able to DM all users on the server, shown here:
[Command("dm")]
public async Task DmAsync()
{
var guild = Program._client.GetGuild(Context.Guild.Id) as IGuild;
await Context.Guild.DownloadUsersAsync();
await Task.Delay(500);
var users = await guild.GetUsersAsync();
foreach (var user in users)
{
var u = user as IGuildUser;
if (!u.IsBot && !u.IsWebhook)
{
IUserMessage dm = await u.SendMessageAsync("Mass dm test", false);
if (dm == null)
{
continue;
}
}
}
}
I was aware one of my friends has my bot blocked, so hence why I am checking if the dm is null. I thought that this would move past the error of The server responded with error 50007: Cannot send messages to this user
, however I was wrong.
How would I go about continuing the foreach loop after this error is given, as it just completely stops the process and I would like the bot to just ignore it and keep sending DMs.