У меня есть код
import logging
import time
import discord
import asyncio
from discord.ext import commands
from discord.utils import get
client = commands.Bot(command_prefix='!')
@client.command()
async def ban(ctx, member: discord.Member = None, time = None, *, reason: str = None):
async def unb(member):
users = await ctx.guild.bans()
for ban_user in users:
if ban_user.user == member:
await ctx.guild.unban(ban_user.user)
if member:
if time:
time_letter = time[-1:]
time_numbers = int(time[:-1])
def t(time_letter):
if time_letter == 's':
return 1
if time_letter == 'm':
return 60
if time_letter == 'h':
return 60*60
if time_letter == 'd':
return 60*60*24
if reason:
await member.ban(reason=reason)
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен \nВремя: {time} \nПричина: {reason}' ))
await asyncio.sleep(time_numbers*t(time_letter))
await unb(member)
await ctx.send(f'Польнзователь {member.mention} разбанен')
else:
await member.ban()
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен \nВремя: {time}'))
await asyncio.sleep(time_numbers*t(time_letter))
await unb(member)
await ctx.send(f'Польнзователь {member.mention} разбанен')
else:
await member.ban()
await ctx.send(embed=discord.Embed(description=f'Пользователь {member.mention} был забанен'))
else:
await ctx.send('Введите имя пользователя')
@client.event
async def on_ready():
print(discord.__version__)
@client.event
async def on_raw_reaction_add(payload):
guild = client.get_guild(payload.guild_id)
member = get(guild.members, id=payload.user_id)
Channel_ID = 1045710900407046224
Message_ID = 1045712195994013726
if payload.channel_id == Channel_ID and payload.message_id == Message_ID:
print(str(payload.emoji)[:7])
if str(payload.emoji)[:10] == "<:kakachi:":
print(str(payload.emoji))
role = get(payload.member.guild.roles, id = 1045723588478632007)
await payload.member.add_roles(role)
if payload.channel_id == Channel_ID and payload.message_id == Message_ID:
if str(payload.emoji)[:7] == "<:work:":
print(str(payload.emoji))
role = get(payload.member.guild.roles, id = 1045725207924576296)
await payload.member.add_roles(role)
client.run("token")
он запускается но когда я пишу в чат о кике команды не работают писал .kick