Python 将编码为discord.py的bot上载到服务器时出现问题

Python 将编码为discord.py的bot上载到服务器时出现问题,python,server,discord,bots,discord.py,Python,Server,Discord,Bots,Discord.py,第一次来这里,我最近制作了一个小的discord机器人,帮助老师在discord课堂上打电话 只要我把机器人上传到自己的电脑上,它就可以正常工作,但让我的电脑一整天都开着要花很多钱。所以,我最近在cursehosting.com上支付了一个服务器的费用,并上传了我的机器人,但在那里,似乎什么都不起作用 这是我的密码: import discord from discord.ext import commands from discord.ext.commands import has_permi

第一次来这里,我最近制作了一个小的discord机器人,帮助老师在discord课堂上打电话

只要我把机器人上传到自己的电脑上,它就可以正常工作,但让我的电脑一整天都开着要花很多钱。所以,我最近在cursehosting.com上支付了一个服务器的费用,并上传了我的机器人,但在那里,似乎什么都不起作用

这是我的密码:

import discord
from discord.ext import commands
from discord.ext.commands import has_permissions,has_role
import logging
from asyncio import sleep
from datetime import datetime
from os import remove

#[==== Affichage des logs
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
#====]

client = commands.Bot(command_prefix = '.')#initialisation du prefix de commande pour le bot
@client.event
async def on_ready():
    """fonction affichant un message au démarrage du bot"""
    print('Bot est démarré.\n')
    
@client.command()
#@has_permissions(administrator=True) #commande exclusive aux enseignants/admins
@has_role("Enseignant")
async def appel(ctx, *, cours = "Cours Non Définit"):
    await client.change_presence(activity=discord.Game(name="Faire l'appel"))
    nom_fichier = "Fiche-Appel-"+cours+"-"+ctx.author.name+".txt"#nom du fichier de l'appel
    
    msg = await ctx.send(f"Le cours __ {cours} __ commence!\n> Merci de signaler votre présence en **cliquant sur le ✅ \
**en réaction de ce message d'ici à 15 minutes :alarm_clock:.\n||Pour que votre présence soit validée, il faut que votre pseudonyme\
 soit votre nom + prénom.||")
    await msg.add_reaction("✅")
    await sleep(900) #=== Valeur à changer, temps (en secondes) durant lequel les élèves peuvent se manifester.

    users = set()
    cache_msg = discord.utils.get(client.cached_messages, id=msg.id)
    for reaction in cache_msg.reactions:
        async for user in reaction.users():
            users.add(user)
    with open(nom_fichier, "w") as file:
        file.write(str(datetime.now()))
        file.write("\nFiche d'appel du cours {}, par {}\n\nEtudiant(e)s présent(e)s:\n".format(cours, ctx.author.name))
        for user in users:
            if user.bot == True: #ne pas register la réaction de BOT
                continue
            if user.nick != None: 
                file.write(str(user.nick)+" \n")
            else: #si l'utilisateur n'a pas de pseudonyme local
                file.write(str(user.name)+" \n")
    with open(nom_fichier, "rb") as file:
        channel = client.get_channel(756267947080548563)
        await channel.send("Fiche d'appel du cours {}, par {}".format(cours, ctx.author.name), file=discord.File(file, nom_fichier))
    try:
        remove(nom_fichier)
    except:
        print("Aucun fichier n'a été trouvé pour la suppression automatique\nfichier recherché : {}".format(nom_fichier))
@appel.error
async def appel_error(error, ctx):
    msg = await ctx.send("Vous n'avez pas les permissions requises pour faire l'appel")
client.run('token')
以下是我在服务器上安装的要求: discord.py/asyncio/datetime 下面是我得到的错误:

忽略命令appel中的异常 回溯(最近一次呼叫最后一次): 文件“/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py”, 第50行,包装好的 ret=来自coro的收益(*args,**kwargs) 文件“main.py”,第29行,在appel中 nom#u fichier=“Fiche Appel-”+cours+“-”+ctx.author.name+“.txt”#nom du fichier de l'Appel AttributeError:“str”对象没有属性“author” 上述异常是以下异常的直接原因: 回溯(最近一次呼叫最后一次): 文件“/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py”, 第846行,进程内命令 从command.invoke(ctx)中获得收益 文件“/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py”, 第374行,在调用中 注入的产量(*ctx.args,**ctx.kwargs) 文件“/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py”, 第54行,已包装 将CommandInvokeError(e)从e中提升 discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:“str”对象没有属性“author”


我不知道我还能给你什么。。。在使用Python3.6时,您是否确保主机上使用的Python版本和所有软件包与个人计算机上使用的相同?提示:不要分发您的机器人令牌。它允许任何拥有它的人在他们的任何服务器上运行代码作为你的机器人。我会重置你的令牌并从你的代码中删除它。嘿,谢谢你的提示,哈哈,我完全忘记了令牌