Discord.py bot不会在聊天中打印SIMPLE变量 [英] Discord.py bot wont print a SIMPLE variable in the chat
本文介绍了Discord.py bot不会在聊天中打印SIMPLE变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要的是机器人说Snacktoshis: 5
,但是它不会在聊天中显示变量.
What I want is for the bot to say Snacktoshis: 5
, but it won't print the variable in the chat.
这是我的代码:
from discord import *
from discord.ext import *
from discord.ext.commands import Bot
from discord.ext.commands import *
import random
import asyncio
from discord import Game
from discord.ext.commands import Bot
import aiohttp
import discord
import requests
import time
BOT_PREFIX = ("?", "!")
client = Bot(command_prefix=BOT_PREFIX)
TOKEN ="3812236138921603126360103210983inserttoken21831382ufsfuadha"
@client.command()
async def bal():
snack = 0
await client.say("Snacktoshis:",snack)
client.run(TOKEN)
我的错误消息是:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send_message() takes from 2 to 3 positional arguments but 4 were given
我知道我有很多未使用的模块.
I know I have alot of unused modules.
推荐答案
我假设您的意思是这样的:
I assume what you mean is something like this:
@bot.command()
async def bal():
snack = 0
await bot.say("Snacktoshis: %d" %snack)
变量应该是消息的一部分,而不是方法调用的单独参数.
Where the variable should be part of the message, and not a separate argument to the method call.
这篇关于Discord.py bot不会在聊天中打印SIMPLE变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文