-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
102 lines (66 loc) · 2.27 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 discord
# import random
import os
# import json
from discord.ext import commands, tasks
from itertools import cycle
messages = 0
status = cycle(['with .help', 'with yo Momma!', 'with Death!', 'with COVID!'])
# def get_prefix(client, message):
# with open("prefixes.json", "r") as f:
# prefixes = json.load(f)
# return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix='.')
# client = commands.Bot(command_prefix = get_prefix)
# cogs
@client.command()
async def load(ctx, extension):
"""Loads a command."""
client.load_extension(f"cogs.{extension}")
@client.command()
async def unload(ctx, extension):
"""Unloads a command."""
client.unload_extension(f"cogs.{extension}")
def loadAll():
for filename in os.listdir("./cogs"):
if filename.endswith('.py'):
client.load_extension(f"cogs.{filename[:-3]}")
loadAll()
# events
@client.event
async def on_ready():
change_status.start()
print("Bot is ready.")
@client.event
async def on_member_join(member): print(f'{member} has joined the server.')
@client.event
async def on_member_remove(member): print(f'{member} has left the server.')
# @client.event
# async def on_guild_join(guild):
# with open("prefixes.json", "r") as f:
# prefixes = json.load(f)
# prefixes[str(guild.id)] = '.'
# with open("prefixes.json", "w") as f:
# json.dump(prefixes, f, indent=4)
# @client.event
# async def on_guild_remove(guild):
# with open("prefixes.json", "r") as f:
# prefixes = json.load(f)
# prefixes.pop(str(guild.id))
# with open("prefixes.json", "w") as f:
# json.dump(prefixes, f, indent=4)
# #commands
# @client.command()
# async def changeprefix(ctx, newprefix):
# with open("prefixes.json", "r") as f:
# prefixes = json.load(f)
# prefixes[str(ctx.guild.id)] = newprefix
# with open("prefixes.json", "w") as f:
# json.dump(prefixes, f, indent=4)
# await ctx.send(f"Prefix changed to: {newprefix}")
# Note to self .... * means to take in all arguments after, as one string
# tasks
@tasks.loop(seconds=1800)
async def change_status():
await client.change_presence(status=discord.Status.online, activity=discord.Game(next(status)))
client.run('NzE0NTI0MjE0NDM4MTMzNzYw.Xsv6hw.j(HACK)JDZy_QiIKUNH7aGDBM9XbJ7MY8')