-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
155 lines (126 loc) · 7.03 KB
/
bot.py
File metadata and controls
155 lines (126 loc) · 7.03 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
import discord
import random
import os
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
intents = discord.Intents.default()
client = Bot(command_prefix=".", intents=intents)
client.remove_command('help')
tagRoleID = None
worker = False
channel = None
@client.event
async def on_ready():
print( 'bot is active now!' )
await client.change_presence( status = discord.Status.online, activity = discord.Game('Потряси сиськами'))
@client.command(pass_contex = True)
@commands.has_permissions( administrator = True )
async def addrole(ctx, role_id):
global tagRoleID
try:
tagRoleID = int(role_id)
role1 = discord.utils.get(ctx.guild.roles, id=tagRoleID)
tagRoleID = None
if role1:
tagRoleID = int(role_id)
await ctx.send(f" 🟢 Роль с ID: **{tagRoleID}** была добавлена!")
else:
await ctx.send(f" 🔴 **{tagRoleID}** - роли с таким **ID** не существует!")
except:
await ctx.send(f" 🔴 **{role_id}** - некоректный **ID** роли!")
@client.command(pass_contex = True)
@commands.has_permissions( administrator = True )
async def addchannel(ctx, channel_id):
global channel
try:
channel = int(channel_id)
channeltest = client.get_channel(channel_id)
if channeltest:
if channel.permissions_for(ctx.guild.me).send_messages:
permissions = channel.permissions_for(ctx.guild.me)
if permissions.add_reactions and permissions.manage_messages:
await ctx.send(f" 🟢 Канал с ID: **{channel}** был добавлен!")
else:
await ctx.send(f" 🔴 **{channel}** - в этом канале у бота **нет прав** добавлять и убирать! реакции")
else:
await ctx.send(f" 🔴 **{channel}** - в этом канале у бота **нет прав** отправлять сообщения!")
else:
await ctx.send(f" 🔴 **{channel}** - роли с таким **ID** не существует!")
except:
await ctx.send(f" 🔴 **{channel_id}** - некоректнный **ID** канала!")
async def advert2(ctx):
role = ctx.guild.get_role(tagRoleID)
role_mention = role.mention
message = await ctx.send(f'❗{role_mention} Время отправки обьявления❗')
await message.add_reaction('✅') # Добавляем реакцию ✅ к сообщению
await message.add_reaction('🧿') # Добавляем реакцию 🧿 к сообщению
@client.command()
async def advert3(ctx, user):
global worker
user_mention = user.mention # Получаем упоминание пользователя
if worker == False:
await ctx.message.remove_reaction('🧿', client.user)
await ctx.send(f"**🟢 {user_mention}** взялся за роботу!")
worker = True
else:
await ctx.send(f"🔴 {user_mention} уже кто-то взялся за роботу!")
@client.command(pass_contex = True)
@commands.has_permissions( administrator = True )
async def advert(ctx):
if tagRoleID != None and channel != None:
await ctx.channel.purge (limit = 1)
emb = discord.Embed( title = 'Отправка обьявлений на маркетплейс', colour = discord.Color.green() )
emb.add_field(name = f'**Как работает📗**', value = 'Каждые 2 часа отправляет напоминание об отправке обьявления на маркетплейс в Дискорде')
emb.add_field(name = f'**Взять работу🛠️**', value = 'Если готовы выставить обьявление, нажмите на реакцию 🧿 под сообщением')
emb.add_field(name = f'**После отправки📨**', value = 'После того как выставили обьявление, нажмите на реакию ✅ под сообщением')
await ctx.send( embed = emb )
await advert2(ctx)
elif tagRoleID == None:
emb = discord.Embed(title='🔴 Ошибка', colour = discord.Color.red() )
emb.add_field(name='**.addrole** "role\'s ID"', value='Перед началом роботы задайте **роль** которая будет отмечаться!')
await ctx.send( embed = emb )
elif channel == None:
emb = discord.Embed(title='🔴 Ошибка', colour = discord.Color.red() )
emb.add_field(name='**.addchannel** "channel\'s ID"', value='Перед началом роботы задайте **канал** в который будут отправляться напоминания!')
await ctx.send( embed = emb )
@client.event
async def on_reaction_add(reaction, user):
# Проверяем, что реакция добавлена к сообщению бота и реакция - "✅" или "🧿"
if user != client.user and str(reaction.emoji) in ['✅', '🧿']:
last_message = reaction.message
desired_channel_id = channel
ctx = await client.get_context(last_message)
if last_message.channel.id == desired_channel_id:
if str(reaction.emoji) == '✅':
await ctx.channel.purge(limit=1)
await last_message.delete()
await asyncio.sleep(2*60*60)
await advert2(last_message.channel)
elif str(reaction.emoji) == '🧿':
await advert3(ctx, user) # Передаем объект пользователя
#roll
@client.command(pass_contex = True)
async def roll( ctx ):
a = random.randint(1,100)
await ctx.send(a)
#call
@client.command()
async def call(ctx, member: discord.Member):
await ctx.channel.purge (limit = 1)
await member.send( f'**{member.nick}**, зайдите в дискорд❗ , вас ждёт -🟩 **{ctx.author.nick}**' )
@client.command(pass_contex = True)
async def help(ctx):
emb = discord.Embed( title = 'Комманды сервера', colour = discord.Color.green() )
await ctx.channel.purge (limit = 1)
emb.add_field(name = f'**.call**', value = 'Позвать пользователя в дискорд')
#emb.add_field(name = f'**kick**', value = 'Кикнуть пользователя с сервера')
emb.add_field(name = f'**.roll**', value = 'Кинуть кубик')
#emb.add_field(name = f'**mute**', value = 'Замутить пользователя')
await ctx.send( embed = emb )
@client.command(pass_contex = True)
@commands.has_permissions( administrator = True )
async def cls(ctx):
await ctx.channel.purge (limit = 100)
key = os.getenv('API')
client.run(key)