Python Forum
Coroutine was never awaited error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coroutine was never awaited error
#1
Good evening,

I am currently trying to programm a discord music bot based on an 1-year-old tutorial. As seen below my code includes some coroutines that need to be awaited, however I get the error that my coroutines could not be awaited. Since I am not very familliar with coroutines I hope someone here knows more about them and can help me:
General informations:
IDE: Thonny
python-version: 3.11.5
os: Windows 10

Further information:
I set the token in terminal before running the file

In my main file I try to run the other files that include the coroutines like this:
bot = commands.Bot(command_prefix="/", intents = intents)
bot.add_cog(music_cog(bot))
The music_gog file looks like this:

class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        
        self.is_playing = False
        self.is_paused = False
        
        self.music_queue = []
        self.YDL_OPTIONS = {"format": "bestaudio", "noplaylist" : "True"}
        self.FFMEPG_OPTIONS = {"before_options" : "-reconnect 1 -reconnected_streamed 1 -reconnect_delay_max 5", "options" : "-vn"}
        
        self.vc = None
and includes serveral coroutines like:

 
@commands.command(name = "pause", help = "Pause the current song")
    async def pause(self, ctx, *args):
        if self.is_playing:
            self.is_playing = False
            self.is_paused = True
            await self.vc.pause()
        elif self.is_paused:
            self.is_playing = True
            self.is_paused = False
            await self.vc.resume()

However I get that error message:
RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(music_cog(bot))


I will attach my files below, feel free to ask me for further information

Thanks in advance

Attached Files

Thumbnail(s)
   

.py   main.py (Size: 653 bytes / Downloads: 68)
.py   music_cog.py (Size: 5.15 KB / Downloads: 57)
.py   help_cog.py (Size: 1.25 KB / Downloads: 73)
Reply
#2
Post a short example that demonstrates the problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get coroutine from a task, and an object from a coroutine? AlekseyPython 2 4,426 Mar-23-2019, 01:41 PM
Last Post: AlekseyPython
  How to add coroutine to a running event loop? AlekseyPython 1 8,170 Mar-21-2019, 06:04 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020