import discord
import asyncio
from discord import Game
from discord.ext import commands
bot = commands.Bot(command_prefix="!",case_insensitive=True)
moneyamount = 0
@bot.event
async def on_ready():
print(bot.user.id)
print("botstart")
game = discord.Game("abc")
await bot.change_presence(status=discord.Status.online, activity=game)
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
@bot.command()
async def say(ctx, arg):
await ctx.send(arg)
@bot.command()
async def addmoney(ctx, arg):
await ctx.send("Added: %s Money to your pocket!" %(arg))
addedmoney = moneyamount + arg
str.replace(moneyamount, addedmoney)
print(moneyamount)
@bot.command()
async def mymoney(ctx):
await ctx.send("you have '%s' money in your pocket!" %(moneyamount))
bot.run("(my token)", bot=True)
一切都很好,但是当我使用第三个命令“ addmoney”命令时,它会产生错误:
unsupported operand type(s) for +: 'int' and 'str'
它不执行'moneyamount + arguments',它也与'mymoney'命令相关(因此,当我始终使用'mymoney'命令时,它总是说我有0钱)。
有人可以告诉我这段代码有什么问题吗?