I keep getting an error when I try to do a command for a discord bot

  bots, discord.py, python

I keep getting an error when I try to do the calc command. The calc command is supposed to let me use the wolframalpha api to do math and assist me with other information as well. I don’t want to use the regular Python math commands, because wolframalpha can do very advanced math that I would like to have.

the error:

Ignoring exception in command calc:
Traceback (most recent call last):
  File "main.py", line 29, in calc
    answer = next(res.results).text
StopIteration

The code:

import discord
import wolframalpha as wf

from discord.ext import commands

bot = commands.Bot(command_prefix='}')

@bot.command()
async def hello(ctx):
    await ctx.send('hi!!!!')


@bot.command()
async def hru(ctx):
    await ctx.send('Im doing great, hbu?')


#THE COMMAND!!!!
@bot.command()
async def calc(ctx):
    def check(m):
        return len(m.content) >= 1 and m.author != bot.user

    await ctx.send("Your Equation: ")
    wftoken = 'ive put my wolframalpha app id here'
    client = wf.Client(wftoken)
    query = await bot.wait_for("message", check=check)
    res = client.query(query)
    answer = next(res.results).text
    await ctx.send(answer)


bot.run('ive put my bot code here')

Source: Python Questions

LEAVE A COMMENT