Answer the question
In order to leave comments, you need to log in
Why is the api not working in my discord.py bot code?
Here is my bot code
import discord
import requests
import json
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.command()
async def ping(ctx):
await ctx.send('pong')
@bot.command()
async def vimeworld(ctx):
r = requests.get('https://api.vimeworld.ru/online')
title = r[0]['total'].json
await ctx.send(title)
bot.run('token')
Answer the question
In order to leave comments, you need to log in
Does not work - displays an error in the console? Or silently does not work?
If silent, wrap the body of vimeworld() in a block
try:
...
except Exception as err:
print(err)
json_data = r.json()
total = json_data['total']
await ctx.send(total)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question