forked from Xelyer/Xelyerbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
33 lines (22 loc) · 769 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import discord
import requests
import json
import dotenv
import os
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True
prefix = "!" # Choose your preferred prefix
bot = commands.Bot(command_prefix=prefix,intents=intents)
@bot.event
async def on_ready():
print(f"Bot is ready! Logged in as {bot.user.name} ({bot.user.id})")
await bot.change_presence(activity=discord.Game('!joke'))
@bot.command()
async def joke(ctx):
response = requests.get("https://official-joke-api.appspot.com/random_joke")
joke = json.loads(response.text)
await ctx.send(f"{joke['setup']}\n{joke['punchline']}")
bot.run(os.getenv('token'))