-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (39 loc) · 1.22 KB
/
main.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
import discord
import json
import requests
from discord.ext import tasks
with open("config.json") as f:
config = json.load(f)
intents = discord.Intents(members=True)
client = discord.Bot(
intents=intents, debug_guilds=config["test_guilds"], owner_id=731604933773885521
)
cogs = ["cogs.help", "cogs.view", "cogs.manage"]
for cog in cogs:
client.load_extension(cog)
@client.event
async def on_ready():
await client.change_presence(
activity=discord.Activity(type=discord.ActivityType.watching, name="planes fly")
)
print("Ready!")
@client.event
async def on_application_command_error(
context: discord.ApplicationContext, error: discord.DiscordException
):
if isinstance(error, discord.ApplicationCommandInvokeError):
msg = await context.respond(
f"This command raised an error!",
ephemeral=True,
)
raise error
@tasks.loop(minutes=5)
async def heartbeat():
print("Sending heartbeat")
requests.post(f"https://uptime.betterstack.com/api/v1/heartbeat/{config['heartbeat']}")
@heartbeat.before_loop
async def heartbeat_is_ready():
await client.wait_until_ready()
heartbeat.start()
if __name__ == "__main__":
client.run(config["token"])