/
Skybot.py
62 lines (43 loc) · 1.35 KB
/
Skybot.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
import discord
import os
import requests
import json
import random
from dotenv import load_dotenv
from discord.ext import commands
from connect4 import *
load_dotenv()
activity=discord.Game(name="Connect4 for fun")
bot=commands.Bot(command_prefix=",", activity=activity, status=discord.Status.idle)
f=open("help.txt","r")
help=f.readlines()
def get_quote():
response=requests.get("https://zenquotes.io/api/random")
jd=json.loads(response.text)
quote=jd[0]['q']
return quote
@bot.event
async def on_ready():
print('I am ready as {0.user}'.format(bot))
@bot.event
async def on_message(message):
caseless_message=(message.content).lower()
if message.author==bot.user:
return
if caseless_message.startswith("hey" or "hello") and message.author!=bot:
await message.channel.send('Hello Sir')
if caseless_message.startswith('inspire'):
await message.channel.send(get_quote())
if caseless_message.startswith('help'):
await message.channel.send(str(help[0]))
await bot.process_commands(message)
@bot.command()
async def clear(ctx,amount=2):
await ctx.channel.purge(limit=amount)
games = []
@bot.command(aliases=['p'])
async def play(ctx,mem:discord.Member):
if (mem !=bot.user):
games.append(connect_4(ctx,bot,mem))
await games[-1].connect4game()
bot.run(os.environ['token'])