-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolidBot.py
More file actions
72 lines (67 loc) · 2.59 KB
/
SolidBot.py
File metadata and controls
72 lines (67 loc) · 2.59 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
import disnake
from confi import TOKEN
import pymysql.cursors
import pymysql
from disnake.ext import commands
from disnake.ext import *
from disnake import *
from disnake.ui import *
import os
import asyncpg
from confi import config
intents = disnake.Intents(messages=True, guilds=True, members=True)
intents = disnake.Intents().all()
client = disnake.Client(intents=intents)
bot = commands.Bot(command_prefix='!', intents=intents, test_guilds=[1125825837791449210])
async def all_members(ctx):
await ctx.send(ctx.guild.members)
bot.remove_command('help')
#Cogs-
for cog in os.listdir(r"/home/container/cogs"):
if cog.endswith(".py") and not cog.startswith("_"):
try:
cog = f"cogs.{cog.replace('.py', '')}"
bot.load_extension(cog)
except Exception as e:
print(f"{cog} не может быть загружен")
raise e
#База данных
@bot.event
async def on_ready():
game = disnake.Game("Уже сокро)")
await bot.change_presence(status=disnake.Status.online, activity=game)
for guild in bot.guilds:
for member in guild.members:
try:
db = pymysql.connect(**config)
try:
with db.cursor() as cursor:
if member == bot.user:
pass
elif cursor.execute("SELECT member_id FROM `s168073_members`.`members` WHERE member_id = %s ", str(member.id)) == 0:
cursor.execute("INSERT INTO `s168073_members`.`members`(member_id, lvl, money, exp, custom) VALUE (%s, '0' , '0', '0',%s)", (str(member.id), str({"card": "card5"})))
db.commit()
finally:
db.close()
except Exception as ex :
print("Bad1")
print(ex)
@bot.event
async def on_member_join(member: disnake.Member):
role = disnake.utils.get(member.guild.roles, name='Не верифициорванный')
try:
db = pymysql.connect(**config)
try:
with db.cursor() as cursor:
if member == bot.user:
pass
else:
cursor.execute("INSERT INTO `s168073_members`.`members`(member_id, lvl, money, exp, custom) VALUE (%s, '0' , '0', '0',%s)", (str(member.id), str({"card": "card5"})))
db.commit()
finally:
db.close()
except Exception as ex :
print("Bad2")
print(ex)
await member.add_roles(role)
bot.run(TOKEN)