首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图用Pycord写一个不和谐的机器人,实现齿轮,而机器人不会上线。与Heroku一起托管的Bot

试图用Pycord写一个不和谐的机器人,实现齿轮,而机器人不会上线。与Heroku一起托管的Bot
EN

Stack Overflow用户
提问于 2022-04-09 04:58:14
回答 1查看 665关注 0票数 0

这是主要代码(注意,我故意排除了这个问题的bot令牌,这不是错误的来源):

代码语言:javascript
复制
from discord.ext import commands
from discord.utils import get
import random
import asyncpraw
import os
import sys

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


@bot.command()
async def load(ctx, extension):
        bot.load_extension(f'cogs.{extension}')

@bot.command()
async def unload(ctx, extension):
        bot.unload_extension(f'cogs.{extension}')

@bot.command()
async def reload(ctx, extension):
        bot.unload_extension(f'cogs.{extension}')
        bot.load_extension(f'cogs.{extension}')

for filename in os.listdir(r".\cogs"):
        if filename.endswith('.py'):
                bot.load_extension(f'cogs.{filename[:-3]}')
bot.run(<TOKEN>)     

这是我创造的齿轮之一:

代码语言:javascript
复制
from discord.ext import commands
import discord

class Help(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        
    
    @commands.Cog.listener()
    async def on_ready(self):
        print('Help Cog Online')

    @commands.command()
    async def helpme(self, ctx):
            emb = discord.Embed(title = 'Help Page!', color = 0xeb4034)
            emb.add_field(name = "====================================",
                                  value = "-----------------------------------------------------------", inline= False)
            emb.add_field(name = "BASIC COMMANDS", value = 'Basic', inline= False)
            emb.add_field(name = "Hello", value = '>hello', inline= True)
            emb.add_field(name = "Rick", value = '>rick', inline= True)
            emb.add_field(name = "Counter +1", value = '>inc', inline= True)
            emb.add_field(name = "Counter -1", value = '>dec', inline= True)
            emb.add_field(name = "Show Count", value = '>showc', inline= True)
            emb.add_field(name = "Reset Counter", value = '>reset', inline= True)
            emb.add_field(name = "====================================",
                                  value = "-----------------------------------------------------------", inline= False)
            emb.add_field(name = "REDDIT COMMANDS", value = 'Share SR Posts', inline= False)
            emb.add_field(name = "Memes", value = '>meme', inline= True)
            emb.add_field(name = "IndianDankMemes", value = '>dankmeme', inline= True)
            emb.add_field(name = "ChemicalReactionGifs", value = '>reaction', inline= True)
            emb.add_field(name = "Facts", value = '>fact', inline= True)
            emb.add_field(name = "PerfectTiming", value = '>wowpics', inline= True)
            emb.add_field(name = "Cute Dogs", value = '>doggie', inline= True)
            emb.add_field(name = "Cute Cats", value = '>kitty', inline= True)
            emb.add_field(name = "Cute Ducks", value = '>duckie', inline= True)
            emb.add_field(name = "Aww", value = '>aww', inline= True)
            emb.add_field(name = "====================================",
                                  value = "-----------------------------------------------------------", inline= False)
            emb.add_field(name = "SASS COMMANDS", value = 'Be sassy', inline= False)
            emb.add_field(name = "Roast Someone", value = '>roast @user', inline= True)
            emb.add_field(name = "Slap Someone", value = '>slap @user', inline= True)
            
            await ctx.send(embed = emb)
            
def setup(bot):
    bot.add_cog(Help(bot))

我不太确定这条路是否正确,因为我正在使用GitHub,而且我对它有点陌生.当我使用GitHub并将其托管在Heroku上时,机器人不会上线。但是,当我在本地运行这些文件时,它确实运行--我尝试过各种GitHub路径,但似乎没有什么不同。注意:我在我的GitHub回购中有必需的Procfile和requirements文件

编辑: Heroku日志

代码语言:javascript
复制
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
 !     Python has released a security update! Please consider upgrading to python-3.8.13
       Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.8.5
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Discovering process types
       Procfile declares types -> worker
-----> Compressing...
       Done: 54.8M
-----> Launching...
       Released v6
       https://test-0510.herokuapp.com/ deployed to Heroku

编辑2:这就是我在构建后点击“视图”时得到的信息。

编辑3:我相信这些是我的日志:

代码语言:javascript
复制
2022-04-09T07:45:32.083418+00:00 app[api]: Deploy fd1e17a7 by user ishnkshyp@gmail.com
2022-04-09T07:45:32.083418+00:00 app[api]: Release v10 created by user ishnkshyp@gmail.com
2022-04-09T07:45:32.643569+00:00 heroku[worker.1]: State changed from crashed to starting
2022-04-09T07:45:35.329607+00:00 heroku[worker.1]: Starting process with command `python ChimkenBotTest.py`
2022-04-09T07:45:35.935258+00:00 heroku[worker.1]: State changed from starting to up
2022-04-09T07:45:37.115367+00:00 app[worker.1]: Traceback (most recent call last):
2022-04-09T07:45:37.115431+00:00 app[worker.1]:   File "ChimkenBotTest.py", line 25, in <module>
2022-04-09T07:45:37.115679+00:00 app[worker.1]:     for filename in os.listdir(r"ChimkenBot/cogs"):
2022-04-09T07:45:37.115760+00:00 app[worker.1]: FileNotFoundError: [Errno 2] No such file or directory: 'ChimkenBot/cogs'
2022-04-09T07:45:37.282695+00:00 heroku[worker.1]: Process exited with status 1
2022-04-09T07:45:37.403838+00:00 heroku[worker.1]: State changed from up to crashed
2022-04-09T07:45:37.453014+00:00 heroku[worker.1]: State changed from crashed to starting
2022-04-09T07:45:40.235384+00:00 heroku[worker.1]: Starting process with command `python ChimkenBotTest.py`
2022-04-09T07:45:40.898743+00:00 heroku[worker.1]: State changed from starting to up
2022-04-09T07:45:40.000000+00:00 app[api]: Build succeeded
2022-04-09T07:45:41.890588+00:00 app[worker.1]: Traceback (most recent call last):
2022-04-09T07:45:41.890609+00:00 app[worker.1]:   File "ChimkenBotTest.py", line 25, in <module>
2022-04-09T07:45:41.890668+00:00 app[worker.1]:     for filename in os.listdir(r"ChimkenBot/cogs"):
2022-04-09T07:45:41.890686+00:00 app[worker.1]: FileNotFoundError: [Errno 2] No such file or directory: 'ChimkenBot/cogs'
2022-04-09T07:45:42.039935+00:00 heroku[worker.1]: Process exited with status 1
2022-04-09T07:45:42.174315+00:00 heroku[worker.1]: State changed from up to crashed```
EN

回答 1

Stack Overflow用户

发布于 2022-04-09 07:54:55

好吧我想明白了。问题就在我指定的道路上。我去找./cogs --我把它改成了cogs,它起了作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71805358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档