This repository was archived by the owner on Mar 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
309 lines (246 loc) · 10 KB
/
main.py
File metadata and controls
309 lines (246 loc) · 10 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import os
import discord
from asyncio import sleep
from discord.ext import commands
from asyncio import tasks
import asyncio
import random
from time import sleep
import datetime
from PIL import Image, ImageFont, ImageDraw
import json
import sys
import platform
from discord import client
from discord.ext import commands, tasks
from config import acces
from discord_components import *
from discord_components import DiscordComponents, Button, ButtonStyle
from Cybernator import Paginator as pag
from discord_buttons_plugin import *
intents = discord.Intents.default()
intents.members = True
intents.all()
client = discord.Client()
client = discord.Client(intents=intents)
client = commands.Bot(command_prefix='m!', intents=intents)
client.remove_command('help')
buttons = ButtonsClient(client)
if not os.path.isfile("config.json"):
sys.exit("'config.json 'не найден! Пожалуйста, добавьте его и попробуйте еще раз.")
else:
with open("config.json") as file:
config = json.load(file)
# Setup the game status task of the client
@client.event
async def on_ready():
print(f"Logged in as {client.user.name}")
print(f"Discord.py API version: {discord.__version__}")
print(f"Python version: {platform.python_version()}")
print(f"Running on: {platform.system()} {platform.release()} ({os.name})")
print("-------------------")
DiscordComponents(client)
status_task.start()
@tasks.loop(minutes=1.0)
async def status_task():
statuses = ["Лисички🦊", f"{config['bot_prefix']}help", "Made by Snak#0017"]
await client.change_presence(activity=discord.Game(random.choice(statuses))
)
# Код в этом даже выполняется, когда бот готов
@client.command()
async def load(ctx, extension):
user = ctx.author.id
if user in acces:
client.load_extension(f'cogs.{extension}') #загружает расширение
await ctx.send(f'Loaded "{extension}"')
return
else:
return
@client.command()
async def unload(ctx, extension):
user = ctx.author.id
if user in acces:
client.unload_extension(f'cogs.{extension}') # выгружает расширение
await ctx.send(f'Unloaded "{extension}"')
return
else:
return
for filename in os.listdir('./cogs'): # загружает все файлы (* .py)
if filename.endswith('.py'):
client.load_extension(
f'cogs.{filename[:-3]}'
) # загружает файл без ".py", например: cogs.ping
@client.event
async def on_message(message):
# Игнорирует выполнение команды ботом или самим ботом
if message.author == client.user or message.author.bot:
return
# Игнорирует, если команда выполняется пользователем из черного списка
with open("blacklist.json") as file:
blacklist = json.load(file)
if message.author.id in blacklist["ids"]:
return
await client.process_commands(message)
@client.event
async def on_command_completion(ctx):
fullCommandName = ctx.command.qualified_name
split = fullCommandName.split(" ")
executedCommand = str(split[0])
print(
f"Написал {executedCommand} команду в {ctx.guild.name} (Guild ID: {ctx.message.guild.id}) написал {ctx.message.author} (Author ID: {ctx.message.author.id}) (Канал: {ctx.channel.name})"
)
#Остальные команды
@client.command() #пинг бота
async def ping(ctx):
embed: discord.Embed = discord.Embed(
title="🏓 Понг!",
description=
f"<a:ping_signal:881200232052965388> Мой пинг {round(client.latency * 1000)}мс.",
color=discord.Color.purple())
embed.set_author(name="")
embed.add_field(name="Есть проблемы? Сервер тех. поддержки",
value="[(тык-тык)](https://discord.gg/ZVA59cZmM7)",
inline=True)
await ctx.send(embed=embed)
#avatar command
@client.command()
async def avatar(ctx, member: discord.Member = None):
if member == None:
member = ctx.author
icon_url = member.avatar_url
avatarEmbed = discord.Embed(title=f"{member.name}\'s аватар")
avatarEmbed.set_image(url=f"{icon_url}")
await ctx.send(embed=avatarEmbed)
@client.command()
async def jack(ctx, *, text="Вы не чего не написали."):
img = Image.open("jack.png")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("Nunito-Regular.ttf", 60)
draw.text((60, 120), text, (0, 0, 0), font=font)
img.save("text.png")
await ctx.send(file=discord.File("text.png"))
#Тестовые команды
@client.command()
async def server(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
id = str(ctx.guild.id)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=name + "\n📚Информация сервера",
description=description,
color=discord.Color.purple())
embed.set_thumbnail(url=icon)
embed.add_field(name="👑 | Овнер",
value=str(ctx.guild.owner.mention),
inline=False)
embed.add_field(name="🆔 | Сервер ID", value=id, inline=False)
embed.add_field(name="🌎 | Регион",
value=f"{ctx.guild.region}".replace("Russia", "").replace(
"Europe", ""),
inline=False)
embed.add_field(name="😀 | Участников", value=memberCount, inline=False)
embed.add_field(name="🔰 | Уровень защиты",
value=f"{ctx.guild.verification_level}".replace(
"very_high",
"Очень высокий").replace("high", "Высокий").replace(
"medium",
"Средний").replace("low", "Низкий").replace(
"None", "Отсутствует"),
inline=False)
time = datetime.datetime.utcnow()
embed.set_footer(
text=time,
icon_url=
"https://images-ext-2.discordapp.net/external/LhmmB4OwWHYfNiB3wwXptPXaKBGX42p1ctaZD24xKjY/https/media.discordapp.net/attachments/809379533572145193/840469160857436162/monica2Bseggos.gif"
)
await ctx.send(embed=embed)
@client.command()
async def help(ctx):
embed1 = discord.Embed(
title="📋 Стандартные команды",
description=
'• `m!ping` - Показывает пинг бота \n • `m!bug - m!idea` - отправка бага-идеи на тех. сервер \n • `m!links` - Полезные ссылки \n • `m!avatar` - показывает аватар участника \n • `m!about` - информация в боте '
)
embed2 = discord.Embed(
title="🛡 Модерирование",
description='• `m!console <ник участника>` - бан или кик участника')
embed3 = discord.Embed(
title="😁 Веселости",
description=
'• `m!automemes <id channel>` - Подключение автопубликации мемов на канал \n • `m!meme` - Присылает рандомный мем \n • `m!jack <Текст>` - жак фреско \n • `m!nsfw` - NSFW команды'
)
embed4 = discord.Embed(
title="💎 Премиум команды",
description=
'• `m!bonus` - Премиум подписка на бота \n • `m!piar` - Информация о заказе рекламы'
)
embed5 = discord.Embed(
title="🎫 Команды разработчика",
description=
'• `m!blacklist <add-remove>` - добавляет участника в черный список бота \n • `m!shotdown` - экстренное отключение бота \n • `m!say` - сказать от имени бота \n • `m!embed` - сказать от имени бота в эмбеде'
)
embeds = [embed1, embed2, embed3, embed4, embed5]
message = await ctx.send(embed=embed1)
page = pag(client, message, only=ctx.author, color=0xF76C12, embeds=embeds)
await page.start()
@client.command()
async def secretinvite(ctx):
embed = discord.Embed(title=f"Инвайт {client.user.name}", color=0x4a16b9, description=f"Хочешь пригласить? {client.user.name}, тогда [кликни сюда](https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=536868679031&scope=bot)")
await buttons.send(
content = None,
embed = embed,
channel = ctx.channel.id,
components = [
ActionRow([
Button(
style = ButtonType().Link,
label = "Инвайт",
url = f"https://discord.com/api/oauth2/authorize?client_id={client.user.id}&permissions=536868679031&scope=bot"
)
])
]
)
@buttons.click
async def hibutton(ctx):
await ctx.reply(f"Привет {ctx.member.name}")
@buttons.click
async def clickbutton(ctx):
await ctx.reply(f"{ctx.member.name} Нажал на кнопку.")
@buttons.click
async def danger(ctx):
await ctx.reply(f"{ctx.member}, Сказал не кликать!")
@buttons.click
async def lol(ctx):
await ctx.reply("Лол")
@client.command()
async def hi(ctx):
await buttons.send(
content="Привет",
channel = ctx.channel.id,
components = [
ActionRow([
Button(
style = ButtonType().Primary,
label = "Привет",
custom_id = "hibutton",
),
Button(
style = ButtonType().Success,
label = "Клик",
custom_id = "clickbutton"
),
Button(
style = ButtonType().Danger,
label = "Не кликай",
custom_id = "danger",
),
Button(
style = ButtonType().Secondary,
label = "Привет",
custom_id = "lol",
)
])
]
)
client.run("")