-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
69 lines (52 loc) · 2.16 KB
/
Copy pathmain.py
File metadata and controls
69 lines (52 loc) · 2.16 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
import discord
import os
from dotenv import load_dotenv
import discord.ext.commands as commands
import discord.ext.tasks as tasks
import logging
import logging.handlers
import asyncio
from pyexpat.errors import messages
from Utils import database
from Cogs import settings, voicelogs, chatlogs, joinlogs, auditlogs
intents = discord.Intents(messages=True, guilds=True, members=True, message_content=True, voice_states=True, moderation=True)
logger = logging.getLogger('discord')
logger.setLevel(logging.WARNING)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
bot = commands.Bot(command_prefix='$$', intents=intents)
bot.add_cog(settings.MyCog(bot))
bot.add_cog(voicelogs.VoiceLogs(bot))
bot.add_cog(chatlogs.Chatlogs(bot))
bot.add_cog(joinlogs.JoinLogs(bot))
bot.add_cog(auditlogs.AuditLogs(bot))
@tasks.loop(minutes=10)
async def presence_update():
await bot.change_presence(activity=discord.Game(name="Guilds: " + str(len(bot.guilds))))
@bot.event
async def on_ready():
print("Bot running, guilds: ", len(bot.guilds))
await bot.change_presence(activity=discord.Game(name="Recently updated"))
for guild in bot.guilds:
if not database.check_if_guild_in_db(guild.id):
database.create_database(guild.id)
database.check_for_changes()
await asyncio.sleep(600)
presence_update.start()
@bot.slash_command(name="ping", description="Check the bot's latency")
async def ping(ctx):
em = discord.Embed(title="Pong!", description=f"{round(bot.latency * 1000)}ms", color=discord.Color.green())
await ctx.respond(embed=em)
@bot.slash_command(name="eval", description="Evaluate code")
@commands.is_owner()
async def evalCommand(ctx, code: str):
try:
result = eval(code)
em = discord.Embed(title="Eval", description=result, color=discord.Color.green())
await ctx.respond(embed=em)
except Exception as e:
em = discord.Embed(title="Error", description=e, color=discord.Color.red())
await ctx.respond(embed=em)
load_dotenv()
bot.run(os.getenv('TOKEN'))