如何在discord.py cogs中使用ban_error和kick_error?

时间:2020-12-24 22:16:28

标签: python discord

我有一个不和谐的机器人,并且已经开始用齿轮来拆分它。但是,有一部分是我无法复制的。通常,在主 py 文件中,我有

@ban.error
async def ban_error(ctx, error):
    if isinstance(error, MissingPermissions):
        await ctx.send(":x: You don't have permissions to ban members.")

@kick.error
async def kick_error(ctx, error):
    if isinstance(error, MissingPermissions):
        await ctx.send(":x: You don't have permissions to kick members.")

然而,这两个监听器并不存在于 cogs 中。如何复制相同的行为?

1 个答案:

答案 0 :(得分:0)

此代码片段有效

import numpy as np

count = 56000
mat = np.zeros((count, count), dtype="float32")  # create a matrix of zeros, if this line succeeds hoora your matrix fits in memory
# mat will take 12.5 GB with float32 (56000^2 x 4 Bytes)

for i in range(count):
    for j in range(i + 1, count):
        mat[i, j] = compute_some_value(i, j)

np.save("matrix.txt", mat)