discord - 我的 discord bot 命令不起作用,但它在 cmd 中有效
问题描述
这是我的命令,它似乎不起作用,但是当我在 cmd 中执行 tfollow {channel} 时,它起作用了,有什么想法吗?我尝试做我知道该怎么做的所有事情,但它似乎对我不起作用,它通过机器人对我的朋友有用
@bot.command() @commands.cooldown(1, 600, type=commands.BucketType.user)
async def tfollow(ctx, channel, amount: int=None):
print(f'{ctx.author} | {ctx.author.id} -> /tfollow {channel}')
if ctx.channel.type != discord.ChannelType.private:
if ctx.channel.id == bots_channel or ctx.author.id in administrators:
if str(channel.lower()) in tfollow_cooldown and ctx.author.id not in administrators:
try:
await ctx.message.delete()
except:
pass
else:
try:
if '-' in str(channel):
raise Exception
max_amount = 0
if ctx.author.id in administrators:
tfollow.reset_cooldown(ctx)
max_amount += 1000
premium = discord.utils.get(ctx.guild.roles, name='Premium')
if premium in ctx.author.roles:
max_amount += 1000
diamond = discord.utils.get(ctx.guild.roles, name='Diamond')
if diamond in ctx.author.roles:
max_amount += 750
gold = discord.utils.get(ctx.guild.roles, name='Gold')
if gold in ctx.author.roles:
max_amount += 450
silver = discord.utils.get(ctx.guild.roles, name='Silver')
if silver in ctx.author.roles:
max_amount += 250
bronze = discord.utils.get(ctx.guild.roles, name='Bronze')
if bronze in ctx.author.roles:
max_amount += 100
booster = discord.utils.get(ctx.guild.roles, name='Booster')
if booster in ctx.author.roles:
max_amount += 75
_75 = discord.utils.get(ctx.guild.roles, name='+75')
if _75 in ctx.author.roles:
max_amount += 75
_25 = discord.utils.get(ctx.guild.roles, name='+25')
if _25 in ctx.author.roles:
max_amount += 25
_10 = discord.utils.get(ctx.guild.roles, name='+10')
if _10 in ctx.author.roles:
max_amount += 10
_5 = discord.utils.get(ctx.guild.roles, name='+5')
if _5 in ctx.author.roles:
max_amount += 5
max_amount += 25
if amount is None:
amount = max_amount
elif amount > max_amount:
amount = max_amount
if amount <= max_amount:
premium = discord.utils.get(ctx.guild.roles, name='Premium')
if premium in ctx.author.roles:
position = len(queue) + 1
# embed = discord.Embed(color=16379747, description=f'Added `tfollow-{channel}-{amount}` to queue! (`1/{position}`)')
embed = discord.Embed(color=16379747, description=f'Adding `{amount}` followers to `{channel}`! (`1/{position}`)')
await ctx.send(embed=embed)
queue.insert(0, f'tfollow-{channel}-{amount}')
else:
position = len(queue) + 1
# embed = discord.Embed(color=16379747, description=f'Added `tfollow-{channel}-{amount}` to queue! (`{position}/{position}`)')
embed = discord.Embed(color=16379747, description=f'Adding `{amount}` followers to `{channel}`! (`{position}/{position}`)')
await ctx.send(embed=embed)
queue.append(f'tfollow-{channel}-{amount}')
if ctx.author.id not in administrators:
tfollow_cooldown.append(str(channel.lower()))
await asyncio.sleep(600)
tfollow_cooldown.remove(str(channel.lower()))
except:
embed = discord.Embed(color=16379747, description='An error has occured while attempting to run this command!')
await ctx.send(embed=embed)
tfollow.reset_cooldown(ctx)
else:
await ctx.message.delete()
tfollow.reset_cooldown(ctx)
解决方案
推荐阅读
- c# - Blazor WASM:ReadFromJsonAsync 时出错
- > 发霉
- c++ - 如何更改 QListWidget 中的滚动条边距
- html - 如何在它的前一个元素上显示一个元素 Vuetify
- python - 使用格式错误的 uid 删除用户时出现错误身份平台
- angular - 如何在 Angular 中处理异常 500 错误消息
- graphql - 具有多个网关但具有相同 DGS 框架的 Graphql
- git - 如何挑选特定作者的提交范围?
- linux-kernel - 错误:驱动程序已注册,正在中止
- anylogic - 导出到 Java 应用程序会删除文件
- elasticsearch - 如何从中心坐标和半径计算地理边界框