Python Forum

Full Version: Help discord bot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! At a command "test" call writes an error in a stream. Help fix

from re import M
import discord, asyncio
from discord.ext import commands
from threading import Thread

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='/', intents=intents)

async def send_msg(channel, text):
    channel = bot.get_channel(channel)
    await channel.send(text)

@bot.command()
async def test (ctx, channel, text):
        th1 = Thread(target=send_msg, args=(channel, text))
        th1.start()

bot.run('bot_token')
Error:
RuntimeWarning: coroutine 'send_msg' was never awaited self._target(*self._args, **self._kwargs) RuntimeWarning: Enable tracemalloc to get the object allocation traceback