# Import discord.py module
import discord
# requests and json modules let you call the Torn API
import requests
import json
# discord.ext has a ton of features for making bots
from discord.ext import commands
# Enter your Discord bot token
# (this should be in a separate file for a real bot)
DISCORD_TOKEN = “YOUR_DISCORD_BOT_TOKEN”
# Define Discord.py variables and permissions
intents = discord.Intents().all()
# Create the bot and assign a command prefix to it
bot = commands.Bot(command_prefix='?', intents=intents)
# Define your API key
# DO NOT DO IT LIKE THIS FOR A REAL BOT!
api = "YOUR_API_KEY"
# set User ID
user = "51498"
# define the Torn API call
call = "https://api.torn.com/user/"+user+"?selections=profile&comment=Pythondemo&key="+api
# Create the command to check up on MaGnO's status
@bot.command(name="magno", help="Check how MaGnO is doing.")
async def chain(ctx):
fed = requests.get(call).json()['status']['state']
if(fed=="Federal"):
msg = "Yes (thank God!)"
else:
msg = "No (hide your API keys!)"
await ctx.send(msg)
# Run the bot itself
bot.run(DISCORD_TOKEN)