-
Notifications
You must be signed in to change notification settings - Fork 1
/
joker.py
101 lines (89 loc) · 3.01 KB
/
joker.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
import discord
from discord.ext import commands,tasks
import os
from itertools import cycle
import random
import requests
import json
import asyncio
import itertools
token = open("token.txt", "r").read()
mainaccid=open("mainaccid.txt", "r").read()
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!joker '),intents=intents)
status=cycle(["Why So Serious!?","JOKER IS HERE","Use !joker or mention me"])
async def is_it_me(ctx):
if(str(ctx.author.id) == mainaccid):
await ctx.send("HELLO MASTERMIND")
return True
else:
await ctx.send("ONLY MASTERMIND(owner of the bot) CAN USE THIS COMMAND")
return False
@bot.event
async def on_ready():
change_status.start()
print('We have logged in as {0.user}'.format(bot))
@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(status=discord.Status.online,activity=discord.Game(next(status)))
# Cogs related functions
@commands.check(is_it_me)
@bot.command()
async def load(ctx,extension):
try:
bot.load_extension(f'cogs.{extension}')
await ctx.send(f"Loaded {extension}")
except Exception as e:
await ctx.send("Error occured:"+e)
@commands.check(is_it_me)
@bot.command()
async def unload(ctx,extension):
try:
bot.unload_extension(f'cogs.{extension}')
await ctx.send(f"Unloaded {extension}")
except Exception as e:
await ctx.send("Error occured:"+e)
@commands.check(is_it_me)
@bot.command()
async def reload(ctx,extension):
try:
bot.unload_extension(f'cogs.{extension}')
bot.load_extension(f'cogs.{extension}')
await ctx.send(f"Reloaded {extension}")
except Exception as e:
await ctx.send("Error occured:"+e)
@commands.check(is_it_me)
@bot.command()
async def loadall(ctx):
try:
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
await ctx.send(f"Loaded all")
except Exception as e:
await ctx.send("Error occured:"+e)
@commands.check(is_it_me)
@bot.command()
async def unloadall(ctx):
try:
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.unload_extension(f"cogs.{filename[:-3]}")
await ctx.send(f"Unloaded all")
except Exception as e:
await ctx.send("Error occured:"+e)
@commands.check(is_it_me)
@bot.command()
async def reloadall(ctx):
try:
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.unload_extension(f"cogs.{filename[:-3]}")
bot.load_extension(f"cogs.{filename[:-3]}")
await ctx.send(f"Reloaded all")
except Exception as e:
await ctx.send("Error occured:"+e)
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
bot.run(token)