@bot.command()
async def mute(ctx, member: discord.Member, duration: str, *, reason: str):
try:
await ctx.message.delete()
duration_mute = int(duration[:1]) # duration = 1h. [0:] = 1
duration_time = str(duration[1:]) # duration = 1h. [:0] = h
duration_timer = None # timedelta
if any(map(duration_time.lower().startswith, ['s', 'с'])):
duration_timer = datetime.datetime.utcnow() + datetime.timedelta(hours=3, seconds=int(duration_mute))
if any(map(duration_time.lower().startswith, ['m', 'м'])):
duration_timer = datetime.datetime.utcnow() + datetime.timedelta(hours=3, minutes=int(duration_mute))
if any(map(duration_time.lower().startswith, ['h', 'ч'])):
duration_timer = datetime.datetime.utcnow() + datetime.timedelta(hours=int(duration_mute)+3)
if any(map(duration_time.lower().startswith, ['d', 'д'])):
duration_timer = datetime.datetime.utcnow() + datetime.timedelta(hours=3, days=int(duration_mute))
a = await member.timeout(duration_timer.astimezone(pytz.timezone("Europe/Moscow")), reason=reason)
embed = discord.Embed(
title="Пользователь замучен",
color=discord.Color.red(),
description=f"Наказан: {member.mention}\nЗамучен: {ctx.author.mention}\nСрок: {duration} мин\nОкончание: {end_time_str}\nПричина: {reason}"
)
await ctx.send(embed=embed)
except discord.Forbidden:
embed = discord.Embed(
title="Ошибка",
color=discord.Color.red(),
description="У меня недостаточно прав для выполнения этой команды."
)
await ctx.send(embed=embed)
except commands.MissingRequiredArgument:
embed = discord.Embed(
title="Ошибка",
color=discord.Color.red(),
description="Некоторые обязательные аргументы отсутствуют. Используйте команду в следующем формате: !mute @пользователь срок_мута(в минутах) причина."
)
await ctx.send(embed=embed)
except commands.BadArgument:
embed = discord.Embed(
title="Ошибка",
color=discord.Color.red(),
description="Неверный формат аргумента. Пожалуйста, проверьте правильность введенных данных."
)
await ctx.send(embed=embed)
sended = 0
for result in results:
if result == message.from_user.id: pass
else:
try:
bot.send_message(result[0], message.text)
sended+=1
except Exception as e: print(f"[Error] {e}")
bot.send_message(message.from_user.id, f"Отправлено {sended} сообщений!")
let prev_command = ""
bot.command('test', (ctx) => {
ctx.reply("Send your text in chat.")
prev_command = "test"
});
bot.on('text', (ctx) => {
if (prev_command == "test") {
ctx.reply(`Ok, your text '${ctx.message.text}'`)
} else {
ctx.reply("Sorry, usage commands!")
}
})
user_phone = "8 928 000 00 00" # Данные пользователя
user_email = "example@example.com" # Данные пользователя
allowed = ["gmail.com", "mail.ru", "yandex.ru"] # Разрещённые почты
# форматируем номер телефона
user_phone = user_phone.replace(" ", "") # Уберём пробелы
if len(user_phone) != 11:
# Длинна номера не равна 11 символам
pass
elif user_email.split("@")[1] not in allowed:
# Почта не верно указана
pass
else:
# Всё хорошо
pass
emb = discord.Embed(title='Ивенты', description=f'Выберите ивент который хотите провести.',
components=[
Button(style=ButtonStyle.gray, label='CodeNames', emoji=''),
Button(style=ButtonStyle.gray, label='Бункер', emoji=''),
Button(style=ButtonStyle.gray, label='Дурак Онлайн', emoji=''),
Button(style=ButtonStyle.gray, label='Шляпа', emoji=''),
Button(style=ButtonStyle.gray, label='Сломанный телефон', emoji='')
])
emb.set_thumbnail(url=ctx.author.avatar_url)
msg = await ctx.send(embed = emb)
@bot.message_handler(commands=['special'])
def mess(message):
for user in joinedUsers:
bot.send_message(user, message.text[message.text.find(' '):])
Вы открыли файл joinedUsers и закрыли попробуйте этот код:
@bot.message_handler(commands=['special'])
def mess(message):
joinedFile = open("joined.txt", "r")
joinedUsers = set ()
for user in joinedUsers:
bot.send_message(user, message.text[message.text.find(' '):])
@client.command()
@commands.has_permissions(view_audit_log = True) #права команды: Просматривать аудит логи
async def say(ctx, *, arg = None):
emb = discord.Embed(description = f'{arg}', color = 0x0944d9) #цвет синий
await ctx.send(embed = emb) #отправка сообщения
@say.error #если у участника нету прав просматривать аудит лог то пишем ему то что у вас не достаточно прав!
async def say_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
emb = discord.Embed(titile = f'Ошибка', description = f'**У вас недостаточно прав!**', color = RED)
emb.set_footer(text = f'{client.user.name} © 2020 | Все права защищены', icon_url = client.user.avatar_url)
await ctx.send(embed = emb, delete_after = 15)