【问题标题】:I succesfully uploaded the file to heroku and it went online but the commands were not working我成功将文件上传到heroku,它上线了,但命令不起作用
【发布时间】:2020-09-03 21:47:25
【问题描述】:

我把这个文件上传到heroku,上传没有任何错误,也成功上线了,但是所有命令都不起作用。

代码是:

import discord
import random
from discord.ext import commands

client = commands.Bot(command_prefix = '.')

@client.event
async def on_ready():
    print('Bot is ready.')

@client.command()
async def ping(ctx):
    await ctx.send(f'Pong! {round(client.latency * 1000)}ms')

@client.command()
async def bye(ctx):
    bye = ['Bye-eth', 
           'Bye puta',
           'See ya later']
    await ctx.send(f'{random.choice(bye)}')

@client.command(aliases = ['hoi', 'hola', 'hi', 'hey', 'bonjour'])
async def hello(ctx):
    hey = ['hola puta', 
           'hello friend',
           "how ya doin'", 
           "What's up", 
           "Heyy",
           'Helo']
    await ctx.send(f'{random.choice(hey)}\nhttps://tenor.com/view/hello-gif-9499692')


@client.command()
async def say(ctx, *, string):
    await ctx.channel.purge(limit = 1)
    await ctx.send(string)



@client.command(aliases = ['8ball'])
async def _8ball(ctx, *, question):
    responses = ['It is certain.', 
                 'It is decidedly so.',
                 'Without a doubt.',
                 'Yes – definitely', 
                 'You may rely on it.', 
                 'As I see it, yes.', 
                 'Most likely.',
                 'Outlook good.',
                 'Yes.', 
                 'Signs point to yes.'  , 
                 'Reply hazy, try again.', 
                 'Ask again later.', 
                 'Better not tell you now.', 
                 'Cannot predict now.', 
                 'Concentrate and ask again.', 
                 "Don't count on it.", 
                 'My reply is no.', 
                 'My sources say no.', 
                 'Outlook not so good.', 
                 'Very doubtful.']
    await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')



@client.command()
async def thank(ctx, *, member):
    await ctx.send(f'thank you {member} :grin:')


@client.command()
async def welcome(ctx, *, member):
    await ctx.send(f'ur welcome {member} :grin:')


@client.command()
async def kill(ctx, *, member):
    await ctx.send(f'oof {member} has been killed :gun:')





client.run('NzExNTQwNzI5OTM1Mjk4NTcw.XsEgTw.HiEuDqPZjsCOxgk3dajkQZcc1Bg')

Procfile 是:worker python puta.py

要求是:discord.py==0.16.12

我认为我也需要在需求列表中添加随机但我不知道如何编写它...我尝试将其写为 random 但它给出了一个错误。

有人可以帮我解决这个问题吗?任何帮助将不胜感激:)

【问题讨论】:

    标签: python heroku discord.py


    【解决方案1】:

    discord.py==0.16.12discord.py 的旧版本,它使用client.send_message 而不是ctx.send。如果您希望当前代码正常工作,则需要在 Heroku 实例上使用更新版本的 discord.py

    截至发帖,discord.py 的最新版本是1.3.3

    【讨论】:

      【解决方案2】:

      问题在于您对discord.py 的要求。 0.16.12 不是您的 discord 机器人工作的版本。尝试删除 ==0.16.12,它应该会自动安装最新版本。

      【讨论】:

      • 别担心!如果对您有帮助,请不要忘记将答案标记为accepted,因为它会让其他有同样问题的人更快地找到解决方案!祝机器人好运:)
      【解决方案3】:

      我看到其他人已经在这里回答了您的问题。但我想补充一些对你来说非常重要的东西。您刚刚在线发布了带有令牌的代码。我建议您在有人滥用您的机器人之前立即重新生成您的令牌。

      【讨论】:

      • Discord 有一个系统,如果它在网上泄露,它会自动重新生成机器人的令牌 - 他们会向您发送 DM like so
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 2021-08-11
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      相关资源
      最近更新 更多