-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
56 lines (49 loc) · 2.04 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
from discord.ext import commands, tasks
import os
from threading import Thread
import time
import re
import lavalink
import discord
from utils.Constants import Constants
from utils.CreateTable import CreateTable
import datetime
from utils.utils import *
import os
import math
def get_prefix(client, message):
data = str(read_database(table_name="config", data_in="prefix", data=f"WHERE guild_id={message.guild.id}"))
if data != "None":
prefix=str(read_database(table_name="config", data_in="prefix", data=f"WHERE guild_id={message.guild.id}"))
return commands.when_mentioned_or(prefix)(client, message)
else:
try:
write_in_database(table_name="config", data_in_name="guild_id", data_in=message.guild.id,
data_for_write_name="prefix", data_for_write="s!")
prefix=str(read_database(table_name="config", data_in="prefix",data=f"WHERE guild_id={message.guild.id}"))
return commands.when_mentioned_or(prefix)(client, message)
except:
pass
class Bot:
def __init__(self, **kwargs):
self.intents = discord.Intents.all()
self.bot = commands.AutoShardedBot(command_prefix=get_prefix, intents=discord.Intents.all())
self.bot.remove_command("help")
self.bot.lavalinkpass = "yourpass"
self.bot.lavalinkport = 6952
for filename in os.listdir('events'):
if filename.endswith('.py'):
self.bot.load_extension(f'events.{filename[:-3]}')
for filename in os.listdir('commands'):
if filename.endswith('.py'):
self.bot.load_extension(f'commands.{filename[:-3]}')
print("-------------------------------\nRunning Bot!")
self.bot.run("ODE0NTAwMzM0ODA2MjM3MjI1.YDewjA.nQHl1UaIFSgE4io3UQ2S_bPGWIA")
class init(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("The bot is ready!")
self.bot.add_cog(Music(self.bot))
Bot()