-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
102 lines (80 loc) · 2.22 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import settings
import os
import discord
from discord.ext import commands
from modules import xkcd, image, flip_a_coin, roll_a_dice, shorten_url
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="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.command(
name="flip_a_coin",
description="Flip a coin game",
brief="flip a coin and send head to tails",
)
async def flip_coin(ctx):
try:
embed = flip_a_coin.coinToss()
await ctx.send(embed=embed)
except Exception as e:
print(e)
await ctx.send("Sorry, something went wrong.")
@bot.command(
name="roll_a_dice",
description="Roll a dice game",
brief="Roll a dice and send result of the head",
)
async def roll_dice(ctx):
try:
embed = roll_a_dice.rollDice()
await ctx.send(embed=embed)
except Exception as e:
print(e)
await ctx.send("Sorry, something went wrong.")
@bot.command(
name="shorturl",
description="shorten a given url",
brief="Short a url",
)
async def short_url(ctx, search_arg):
try:
embed = shorten_url.urlShortner(search_arg)
await ctx.send(embed=embed)
except Exception as e:
print(e)
await ctx.send("Sorry, something went wrong.")
bot.run(TOKEN)