我正在尝试将另一个Python脚本的输出添加到我的Discord bot。 我的第一个脚本“clash.py”可以工作,我有一个结果:一个项目列表,它可以在我的操作系统上工作(Raspbian) 当用户发送特定命令时,我想将其置于不协调状态:!克兰特
其工作原理如下:
import discord
from discord.ext import commands
TOKEN = 'Token'
description = '''Merluchon Bot'''
bot = commands.Bot(command_prefix='!', description=description)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
bot.command()
async def Mousse(ctx):
"""Cadeau pour le peuple"""
await ctx.send("https://viesdamelie.files.wordpress.com/2014/07/bain.gif")
bot.run(TOKEN)
如何以这种方式在命令上添加“clash.py”的结果:
async def clantest(ctx):
"""Cadeau pour le peuple"""
await ctx.send("clash.py")
即使我知道这不是它应该是的方式,你看到的想法
非常感谢
您需要在clash.py文件中创建一个可调用函数
差不多
然后,可以在discord bot文件的顶部导入clash.py文件,就像当前导入其他LIB(或多个文件)一样
然后从clantest bot命令内部调用函数
相关问题 更多 >
编程相关推荐