omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. TRGCapn

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    TRGCapn

    @TRGCapn

    0
    Reputation
    691
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    TRGCapn Unfollow Follow

    Latest posts made by TRGCapn

    • RE: async def not registering the function as a coroutine

      Well for some weird reason, it just started working again. I did absolutely nothing to change it and yet when I tried it again for the hundredth time, it worked. Problem Solved?

      posted in Pythonista
      TRGCapn
      TRGCapn
    • RE: async def not registering the function as a coroutine

      @JonB And here is a stripped down version of my code with just one function. All it does now is if a user sends “!hello” the bot will respond with “Hello There”. It still doesn’t work and has the same error, maybe you can try and fix it? You will have to use your own token because I’m not comfortable giving that away as it would give complete and total access over my bot and servers.

      import discord
      from discord.ext import commands
      import asyncio
      import tokens
      
      TOKEN = tokens.my_token
      
      bot = commands.Bot(command_prefix = "!")
      
      @bot.command(pass_context = True)
      async def hello(ctx):
      	await bot.say("Hello There!")
      	
      bot.run(TOKEN)
      
      posted in Pythonista
      TRGCapn
      TRGCapn
    • RE: async def not registering the function as a coroutine

      @JonB Full Traceback:
      Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/9378EF36-EE10-41EA-8875-F8ADFD217EE5/Pythonista3/Documents/CapnBot/CapnBot/CapnBot/CapnBotV1.2.8.py", line 71, in <module>
      @bot.command(pass_context = True)
      File "/private/var/mobile/Containers/Shared/AppGroup/9378EF36-EE10-41EA-8875-F8ADFD217EE5/Pythonista3/Documents/site-packages-3/discord/ext/commands/core.py", line 573, in decorator
      result = command(*args, **kwargs)(func)
      File "/private/var/mobile/Containers/Shared/AppGroup/9378EF36-EE10-41EA-8875-F8ADFD217EE5/Pythonista3/Documents/site-packages-3/discord/ext/commands/core.py", line 680, in decorator
      raise TypeError('Callback must be a coroutine.')
      TypeError: Callback must be a coroutine.

      posted in Pythonista
      TRGCapn
      TRGCapn
    • RE: async def not registering the function as a coroutine

      @JonB I have gotten things running before and force quitting didn’t help, but I’ve tried it multiple times. Printing the full traceback shows that the error is being raised in core.py of the discord module, making me think that is the screwed up one, not asyncio! Even so, I tried completely reinstalling discord.py, but that didn’t work so I’m confused about that. I checked and the function running is in fact asyncio.iscoroutinefunction so that’s not what is causing the error. I don’t know how to use pdb, but when I used the command you gave me the same thing popped up as in the Traceback, just not as an error message.

      posted in Pythonista
      TRGCapn
      TRGCapn
    • RE: async def not registering the function as a coroutine

      @mikael It is actually a TypeError and I am using the regular version (0.16.12).

      posted in Pythonista
      TRGCapn
      TRGCapn
    • RE: async def not registering the function as a coroutine

      @ccc I am currently running on Python 3.6

      posted in Pythonista
      TRGCapn
      TRGCapn
    • async def not registering the function as a coroutine

      I am making a bot for discord and it requires Asyncio, but I am running into an error when I try to define my functions. This has never happened before, but I am now getting a “Callback must be a coroutine” error on all of my functions. Here is an example of one of those functions:

      @bot.command(pass_context = True)
      async def ping(ctx):
          '''-> Pings Bot'''
          channel = ctx.message.channel
          t1 = time.perf_counter()
          await bot.send_typing(channel)
          t2 = time.perf_counter()
          await bot.say(':ping_pong: Pong! - {}'.format(round((t2-t1)*1000)) + "ms")
      

      This raises an error for no apparent reason because I am using async def to define the function. Any help would be appreciated!

      posted in Pythonista
      TRGCapn
      TRGCapn