import string, json, datetime import discord, os from discord.ext import commands import asyncio class Buttooons(discord.ui.View): def __init__(self, *, timeout=180): super().__init__(timeout=timeout) @discord.ui.button(label='клик!', style=discord.ButtonStyle.gray) async def grey_button(self, button:discord.ui.Button, interaction:discord.Interaction): print(f'Клин произошел {datetime.datetime.now()}') intents = discord.Intents.all() intents.message_content = True token = 'MTE0MzQ3NDM5NTc2Mzk3MDE3Mg.GBzL2u.35x0fRB_wvtoSsNHuVUkIlVx7lDSP5HNB5Ipxk' bot = commands.Bot(command_prefix='//', intents=intents) @bot.event async def on_ready(): print('Good') @bot.command() async def test(ctx): await ctx.send('Я теперь тут!') @bot.command() async def infor(ctx, arg=None): await ctx.channel.purge(limit=1) after_mes = ctx.message.author if arg == None: await ctx.send(f'{after_mes.mention}\nВведите:\n//infor общее\n//infor команды') elif arg == 'общее': await ctx.send(f'{after_mes.mention}\nЯ - бот, слежу за порядком в чате!') elif arg == 'команды': await ctx.send(f'{after_mes.mention}\n//schet - калькулятор') else: await ctx.send(f'{after_mes.mention},\nТакой команды нет!') @bot.command() async def sent(ctx): await ctx.message.author.send('Круто!!!') @bot.command() async def mail(ctx, member:discord.Member): await member.send(f'{member.name}, привет от {ctx.author.name}') @bot.command() async def bAAn(ctx, member:discord.Member, *, reason=None): await ctx.channel.purge(limit=1) if ctx.message.author.guild_permissions.administrator: await ctx.send(f'Участник {member.mention} был забанен!') await member.ban(reason=reason) await asyncio.sleep(5) await member.unban() await member.send(f'{await ctx.channel.create_invite(max_age=300)}') else: ctx.send('Отказано') @bot.event async def on_member_join(member): talk = discord.utils.get(member.guild.roles, name='talk') sour = discord.utils.get(member.guild.roles, name='Обыватель') live = discord.utils.get(member.guild.roles, name='Жители Лугиники') await member.add_roles(talk) await member.add_roles(sour) await member.add_roles(live) for ch in bot.get_guild(member.guild.id).channels: if ch.name == 'welcome': talk = discord.utils.get(member.guild.roles, name='talk') sour = discord.utils.get(member.guild.roles, name='Обыватель') await bot.get_channel(ch.id).purge(limit=1) await bot.get_channel(ch.id).send(f'{member.mention} присоединился на сервер!') @bot.event async def on_member_remove(member): for ch in bot.get_guild(member.guild.id).channels: if ch.name == 'основной': await bot.get_channel(ch.id).send(f'{member.mention} покинул этот сервер(') @bot.command() async def buttoon(ctx): await ctx.send('Вот кнопка', view=Buttooons()) client = discord.Client() @bot.command() async def mute_time(ctx, member:discord.Member, time): await ctx.channel.purge(limit=1) if ctx.message.author.guild_permissions.administrator: # mute = discord.utils.get(member.guild.roles, name='muted') talk = discord.utils.get(member.guild.roles, name='talk') await ctx.send(f'{member.mention} был замьютен на {time} секунд BY {ctx.message.author.mention}') # await member.add_roles(mute) await member.remove_roles(talk) await asyncio.sleep(int(time)) await member.add_roles(talk) # await member.remove_roles(mute) else: ctx.send('Отказано') @bot.command() async def clear(ctx, number=100): await ctx.channel.purge(limit=1) if ctx.message.author.guild_permissions.administrator: await ctx.channel.purge(limit=number) else: await ctx.send('Отказано в доступе') @bot.command() async def mute(ctx, member:discord.Member): await ctx.channel.purge(limit=1) if ctx.message.author.guild_permissions.administrator: # mute = discord.utils.get(member.guild.roles, name='muted') talk = discord.utils.get(member.guild.roles, name='talk') # await member.add_roles(mute) await member.remove_roles(talk) await ctx.send(f'{member.mention} был замьютен by {ctx.message.author.mention}') else: ctx.send('Отказано') @bot.command() async def unmute(ctx, member:discord.Member): await ctx.channel.purge(limit=1) if ctx.message.author.guild_permissions.administrator: # mute = discord.utils.get(member.guild.roles, name='muted') talk = discord.utils.get(member.guild.roles, name='talk') await member.add_roles(talk) # await member.remove_roles(mute) await ctx.send(f'{member.mention} был размьютен by {ctx.message.author.mention}') else: ctx.send('Отказано') @bot.command() async def hello(ctx, number=1): await ctx.channel.purge(limit=number) await ctx.send(f'Приветствую тебя, {ctx.message.author.mention}') @bot.command() async def schet(ctx, nub_1, znak, nub_2): nub_1 = int(nub_1) nub_2 = int(nub_2) if znak == '+': await ctx.send(nub_1+nub_2) elif znak == "-": await ctx.send(nub_1-nub_2) elif znak =='/' or znak == ':': await ctx.send(nub_1/nub_2) elif znak == '*': await ctx.send(nub_1*nub_2) bot.run(token)