我正在尝试从 replit 添加一个不属于我的不和谐齿轮。我完全没有使用齿轮的经验,所以这对我来说很困惑。我让机器人工作了,但实际的 sudo 命令没有,因为它不理解你输入到 sudo 的消息。我将如何修复机器人?
from copy import copy
import discord
from discord.ext import commands
__version__ = "1.0.0"
class SudoCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(
hidden = True
)
#@commands.is_owner()
async def sudo(self, ctx, victim: discord.Member, *, command):
"""Take control."""
new_message = copy(ctx.message)
new_message.author = victim
new_message.content = ctx.prefix + command
await self.bot.process_commands(new_message)
def setup(bot):
bot.add_cog(SudoCog(bot))
编辑:这是第二个python文件
import re
from pathlib import Path
import setuptools
def getLongDescription():
with open("README.md", "r") as fh:
longDescription = fh.read()
return longDescription
def getRequirements():
requirements = []
with open("requirements.txt") as f:
requirements = f.read().splitlines()
return requirements
def getVersion():
path = Path(__file__).parent.resolve() / "sudo.py"
with open(path, "r") as fp:
version_file = fp.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if not version_match:
raise RuntimeError("Unable to find version string.")
version = version_match.group(1)
return version
setuptools.setup(
name="DigiSudo",
version=getVersion(),
author="DigiDuncan",
author_email="digiduncan@gmail.com",
description="Sudo command cog for discord.py.",
long_description=getLongDescription(),
long_description_content_type="text/markdown",
url="https://github.com/DigiDuncan/DigiSudo",
python_requires=">=3.7",
install_requires=getRequirements(),
py_modules=["sudo"],
include_package_data=True,
classifiers=[
"Programming Language :: Python :: 3.7",
"Operating System :: OS Independent",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
]
)