(Discord.py-rewrite) 命令执行没有错误,但不起作用

时间:2021-07-01 12:26:05

标签: python discord.py

嘿,出于某种原因,这段代码在我执行时没有发送任何消息,也没有抛出任何错误。我认为这是嵌入的问题,但我似乎无法弄清楚问题出在哪里。有什么帮助吗?谢谢。

import discord
from discord.ext import commands
import os
import json
import requests
import random
from random import randrange
from random import randint
import asyncio
import time
from itertools import cycle
import math


@client.command(aliases=["hacker", "hacking", "hax"])
async def hack(ctx):
    diffrent_hacks_msg = [
        "hacked the goverment and earned",
        "hacked the FBI and earned",
        "hacked a bank and earned",
        "hacked a charity and earned",
        "hacked the presidents bank account and earned",
        "hacked a normal citizen and earned",
        "hacked a crypto coin and earned",
        "hacked the CIA and earned",
        "hacked a police officer and earned",
        "hacked the police departament and earned",
        "hacked a bank truck and earned",
        "hacked the IRS and earned",
        "hacked a friend and earned",
        "hacked Google and earned",
        "hacked Youtube and earned",
        "hacked Twitch and earned",
        "hacked a government official and earned",
        "hacked Walter White and earned",
    ]

    caughtmanmsg = ["FBI", "CIA", "police", "government", "IRS"]

    randomhackmsg = random.choice(diffrent_hacks_msg)
    randomcaught = random.choice(caughtmanmsg)
    earned = random.int(1, 2500000)
    hacksucc = random.int(1, 7)
    hackfail = randomhackmsg.replace(" and earned", "")

    if hacksucc == 1:
        embedhs = discord.Embed(
            title=f"YO HOW?",
            description=f"{ctx.author.mention} {randomhackmsg} {earned} DKC!",
            color=0xCFCFCF,
            timestamp=ctx.message.created_at,
        )
        embedhs.set_footer(text=f"Requested by {ctx.author.name}")
        await ctx.send(embed=embedhs)
    elif hacksucc != 1:
        embedhf = discord.Embed(
            title=f"Unlucky...",
            description=f"{ctx.author.mention} {hackfail}, but got caught by the {randomcaught}...",
            color=0xCFCFCF,
            timestamp=ctx.message.created_at,
        )
        embedhf.set_footer(text=f"Requested by {ctx.author.name}")
        await ctx.send(embed=embedhf)

1 个答案:

答案 0 :(得分:0)

没有random.int这样的东西,你正在寻找random.randint

earned = random.randint(1, 2500000)
hacksucc = random.randint(1, 7)