-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
92 lines (72 loc) · 2.42 KB
/
main.py
File metadata and controls
92 lines (72 loc) · 2.42 KB
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
import os
import topgg
import asyncio
from pyrandmeme import *
from discord.ext import tasks
from datetime import datetime
from discord.ext import commands
from discord_slash import SlashCommand
from loadcog import list_ext
# Intents
intents = discord.Intents.default()
intents.members = True
# Bot Info Setup
client = commands.Bot(command_prefix="#", intents=intents)
slash = SlashCommand(client, sync_commands=True, sync_on_cog_reload=True)
client.remove_command("help")
client.launch_time = datetime.utcnow()
# Load TOPGG
dbl_token = os.environ["TOPTOKEN"]
client.topggpy = topgg.DBLClient(client, dbl_token, autopost=True)
# Loop
async def status_task():
while True:
await client.change_presence(activity=discord.Game(name="/help | #help"))
await asyncio.sleep(10)
await client.change_presence(
activity=discord.Game(name=f"{len(client.guilds)} servers!")
)
await asyncio.sleep(10)
@client.event
async def on_ready():
print("Bot Is Online")
client.loop.create_task(status_task())
all_cogs = list_ext()
for cogs in all_cogs:
client.load_extension(cogs)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print("Failed to post server count\n{}: {}".format(type(e).__name__, e))
@client.command()
async def ping(ctx):
await ctx.send('Pong! {0}'.format(round(client.latency, 1)))
@client.command()
@commands.is_owner()
async def update(ctx, news):
await ctx.send(news)
@client.event
async def on_message(message):
if message.author.bot:
return
elif client.user in message.mentions:
embed = discord.Embed(
title="Hey! Im DisSlash",
description="Use `#help` Or `/help` For More Info!",
)
await message.channel.send(embed=embed)
await client.process_commands(message)
@client.command()
async def uptime(ctx):
delta_uptime = datetime.utcnow() - client.launch_time
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)
await ctx.send(f"{days}d, {hours}h, {minutes}m, {seconds}s")
update_stats.start()
TOKEN = os.environ["TOKEN"]
client.run(TOKEN)