M
M
Moto Moto2021-07-31 13:10:00
Python
Moto Moto, 2021-07-31 13:10:00

How to link njit decorator to discord.py decorators?

hi, just started writing a bot

import discord;
from discord.ext import commands;

import asyncio
from numba import njit

bot = commands.Bot(
    command_prefix="!"
)

@bot.event
async def on_ready():
    print("СТАААРТ!!!!!!!!!!");

# @bot.command()
# async def test(ctx):
#     await ctx.send("ТЫ НЕ ЗЛОЙ ТЫ НЕ ЗЛОЙ ТЫ НЕ ЗЛОЙ ТЫ НЕ ЗЛОЙ");

# @bot.command()
# async def test2(ctx,arg):
#     await ctx.send(arg);

# @bot.command()
# async def test3(ctx,*,arg):
#     await ctx.send(arg);


# ENGLISH COMMANDS

bot.remove_command("help");

@bot.command()
@njit
async def help(ctx):
    author = ctx.message.author;
    sent_message = await ctx.send(author.mention,
        embed = discord.Embed(
            title = "Help",
            description = "**!ban** - ban users...\n**/unban** - unban users\n**/kick** - kick users\n\n**/mute** - mute users\n**/unmute** - unmute users",
            color = discord.Colour.from_rgb(245, 73, 73)
            )
        );
    await asyncio.sleep(15)
    await sent_message.delete()

@bot.command()
async def info(ctx):
    await ctx.send(
        embed = discord.Embed(author.mention,
            title = "Info",
            description = "впадлу писать",
            color = discord.Colour.from_rgb(245, 73, 73)
            )
        );

@bot.command()
async def ban(ctx,arg):
    pass

@bot.command()
async def unban(ctx,arg):
    pass

@bot.command()
async def mute(ctx,arg):
    pass

@bot.command()
async def unmute(ctx,arg):
    pass



bot.run("token");


And I have a problem:
The @njit decorator in conjunction with @bot.command throws an error.
The question is, can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2021-07-31
@longclaps

What for? Do you have a highload there? Not? Well, breathe out, saw your functionality.

V
Vasily Bannikov, 2021-07-31
@vabka

Well, apparently you can't combine them.
Try to give up one or the other.
If you refuse from bot.command, then you will have to write event processing by hand, and if from njit, then the speed will drop a little.
If speed is important, then conduct performance tests, and evaluate the criticality of losses

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question