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.

Sending a message to a channel with cooldown enabled doesn't work nor does it raise an error

See original GitHub issue

Summary

So basically, if you try bot.fetch_channel() then try to send a message to that channel, WHILE from the client you can’t send a message because of the cooldown, it’s not gonna work, and it’s not gonna raise an error

Reproduction Steps

I was trying to automate the process of sending messages to multiple channels, their IDs were stored as integers in a list. I looped over the list and tried fetching the channel and sending a message to it, and it happened that the first ID in the list was an ID of a channel that I had already sent a message to before, but I wanted to use it as a test, basically, if I put it in a try/except block, and I wanted to send a message to the channel, and print an error message if I faced an error, but it didn’t even print, and the message was NOT sent. I removed it out of the try/except block, nothing changed, no error was raised. All the indentation was valid, I had no errors in the code and everything was defined as well.

Code

example_list = [channel_id_1, channel_id_2]
# channel_id_1 is an ID of a channel that you cannot send a message to in the client due to cooldown
# channel_id_2 is an ID of a channel that you can send a message to
# Results are the same inside of commands and events
for ID in example_list:
  try: # Doesn't matter if it was inside or outside of a try/except block
    channel = await bot.fetch_channel(ID)
  except:
    # something
    pass
  else:
    try: # Doesn't matter if it was inside or outside of a try/except block
      await channel.send("any message") # Doing await ctx.send(channel) works, only channel.send doesn't work and it doesn't raise an exception/error
    except:
      # something
      pass
    # now it'll stop the whole for loop, not even continue to the next ID in the list.

Expected Results

Send a message and if it failed, raise an exception.

Actual Results

Weirdly stops and doesn’t raise an exception.

System Information

  • Python v3.10.1-final
  • discord.py-self v1.9.1-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.19042

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn’t visible in the code).

Additional Information

No response

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Sxvxgeecommented, Jan 13, 2022

Shouldn’t there be something like a print statement that makes it clear for people or something? Also what’s a proper way of achieving my goal if that’s what the library is going to do?

0reactions
TheOnlyWayUpcommented, Jan 19, 2022

@dolfies why is this issue still open, it’s usually common practice to close issues if there’s nothing more to add. Comments can still be added to close issues, and reopened if it was closed by the author themselves.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My discord.py edited cooldown doesn't work - Stack Overflow
It looks like we have to force the commands to always share a CooldownMapping object. That's pretty easy, but it means that the...
Read more >
Interactions API Reference - discord.py - Read the Docs
This is a lower level interface to InteractionMessage.delete() in case you do not want to fetch the message and save an HTTP request....
Read more >
Streamlabs Desktop Chatbot FAQs & Troubleshooting ...
Yes, You have to keep the program open and connected for the bot to be in your channel. Does this bot replace Stream...
Read more >
Setting Up Moderation for your Twitch Channel
Learn how to configure your channel moderation settings. This guide covers chat moderation settings, settings related to other areas of your channel, ...
Read more >
How to use Apple Fitness+
After your workout ends, you can review your results or start a Mindful Cooldown. Work out on Apple TV. Open the Fitness app....
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