-
Notifications
You must be signed in to change notification settings - Fork 9
/
bot.py
59 lines (44 loc) · 1.43 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import settings
import os
from modules import news, image
import discord
from discord.ext import commands
from modules import xkcd
TOKEN = os.getenv('DISCORD_BOT_API_TOKEN')
bot = commands.Bot(command_prefix='$', description='Just A Rather Very Intelligent System, now on Discord!')
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def greet(ctx):
await ctx.send(":smiley: :wave: Hello, there!")
@bot.command(name='xkcd',
description='Retrieves a random xkcd comic through external API call',
brief='Retrieves a random xkcd comic')
async def get_xkcd(ctx):
try:
embed = xkcd.process()
await ctx.send(embed=embed)
except Exception as e:
print(e)
await ctx.send("Sorry, something went wrong.")
@bot.command(name='news',
description='Retrieves a random top headline from NewsAPI',
brief='Retrieves a top headline')
async def cmd_news(ctx):
await ctx.send(embed=news.top_headlines())
@bot.command(
name='image',
description='Searches an image from google search engine',
brief='Search an image')
async def search_image(ctx, search_arg):
try:
embed = await image.process(search_arg)
await ctx.send(embed=embed)
except Exception as e:
print(e)
await ctx.send("Sorry, something went wrong.")
bot.run(TOKEN)