import discord
from discord.ext import commands
import asyncio
|
@bot.command()
@commands.has_guild_permissions(administrator=True)
async def mute(ctx, member: discord.Member, duration: str, reason):
guild = bot.get_guild(975494474098679869)
role = guild.get_role(975494474480369721)
channel = guild.get_channel(975494474719461431)
time = {"s": 1, "m": 60, "h": 3600, "d": 86400}
duration_seconds = int(duration[:-1]) * time[duration[-1]]
await member.add_roles(role)
await channel.send(f"Из {member.mention} сделали {role.name} на {duration}, по причине {reason}!")
await asyncio.sleep(duration_seconds)
await member.remove_roles(role)
await channel.send(f"{role.name} был сделан из {member.mention}!")
Этот код работает и в pycharm и в Visual studio Code