diff --git a/cogs/coins.py b/cogs/coins.py new file mode 100644 index 0000000..b870377 --- /dev/null +++ b/cogs/coins.py @@ -0,0 +1,20 @@ +from disnake.ext import commands +import random +import asyncio + + +class coins(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.slash_command() + async def coins(self, ctx): + coin = ["Орел", "Решка"] + result = random.choice(coin) + await ctx.send(f"Орел или решка? Угадайте! Результат будет через 3 секунды...") + await asyncio.sleep(3) + await ctx.send(f"Результат: {result}!") + + +def setup(bot): + bot.add_cog(coins(bot)) \ No newline at end of file diff --git a/cogs/commands.py b/cogs/commands.py new file mode 100644 index 0000000..e492f04 --- /dev/null +++ b/cogs/commands.py @@ -0,0 +1,19 @@ +import disnake +from disnake.ext import commands + +class help1(commands.Cog): + def __init__(self, bot): + self.bot = bot + + + @commands.slash_command() + async def commands(self, ctx): + embed = disnake.Embed(title="Помощь по командам", description="Вот список всех моих команд и их описания:") + embed.add_field(name="$help", value="Показывает список всех доступных команд.") + embed.add_field(name="$ping", value="Проверка работоспособности бота.") + embed.add_field(name="$coins", value="Игра Орел и Решка.") + embed.add_field(name="$mute", value="Выдает мут участнику на определенное время.") + await ctx.send(embed=embed) + +def setup(bot): + bot.add_cog(help1(bot)) \ No newline at end of file diff --git a/cogs/magshar.py b/cogs/magshar.py new file mode 100644 index 0000000..28c8c3f --- /dev/null +++ b/cogs/magshar.py @@ -0,0 +1,22 @@ +import random + +from disnake.ext import commands + +class shar(commands.Cog): + def __init__(self, bot): + self.bot = bot + + + @commands.slash_command() + async def шар(self,ctx, *, question): + answers = [ + "Я не знаю.", + "Да.", + "Нет.", + "Возможно.", + "Спроси позже." + ] + await ctx.send(f"Ваш вопрос: {question}\nМой ответ: {random.choice(answers)}") + +def setup(bot): + bot.add_cog(shar(bot)) \ No newline at end of file diff --git a/cogs/ping.py b/cogs/ping.py new file mode 100644 index 0000000..22fa682 --- /dev/null +++ b/cogs/ping.py @@ -0,0 +1,14 @@ +from disnake.ext import commands + +class Ping(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.has_any_role(1091637465858715648) + @commands.slash_command() + async def ping(self, interaction): + await interaction.response.send_message("Понг!") + + +def setup(bot): + bot.add_cog(Ping(bot)) \ No newline at end of file diff --git a/cogs/test.py b/cogs/test.py new file mode 100644 index 0000000..4d7b25b --- /dev/null +++ b/cogs/test.py @@ -0,0 +1,31 @@ +import asyncio + +import disnake +from disnake.ext import commands + +class mute(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.slash_command() + @commands.has_permissions(manage_roles=True) + async def mute(self, ctx, member: disnake.Member, time: int, *, reason=None): + guild = ctx.guild + mutedRole = disnake.utils.get(guild.roles, name="Muted") + + if not mutedRole: + mutedRole = await guild.create_role(name="Muted") + + # Проверка роли на каждый чат + for channel in guild.channels: + await channel.set_permissions(mutedRole, speak=False, send_messages=False) + + await member.add_roles(mutedRole, reason=reason) + await ctx.send(f"{member.mention} был замучен на {time} секунд. Причина: {reason}.") + await asyncio.sleep(time) + await member.remove_roles(mutedRole) + await ctx.send(f"{member.mention} больше не замучен.") + + +def setup(bot): + bot.add_cog(mute(bot)) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..f0f3ad5 --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +import disnake +from disnake.ext import commands +import os + +intents = disnake.Intents.all() +bot = commands.Bot(command_prefix="$", intents=intents) + +@bot.event +async def on_ready(): + print("Bot is ready") + + +@bot.command() +@commands.has_guild_permissions(administrator=True) # administrator=True - значит что использовать команду может человек только с правом администратора +async def setmoderator(ctx, member: disnake.Member): + member = member or ctx.message.author + guild = bot.get_guild(1060537877982887957) + role = guild.get_role(1060541642450411560) + await member.add_roles(role) + await ctx.send(f"Пользователю {member.mention} была выдана роль {role.mention}") + +@bot.command() +@commands.has_guild_permissions(administrator=True) # administrator=True - значит что использовать команду может человек только с правом администратора +async def dellmoderator(ctx, member: disnake.Member, moder_level: int): + member = member or ctx.message.author + guild = bot.get_guild(1060537877982887957) + role = guild.get_role(1060541642450411560) + await member.remove_roles(role) + await ctx.send(f"Пользователю {member.mention} была снята роль {role.mention}") + + + + + +for filename in os.listdir("./cogs"): + if filename.endswith(".py"): + bot.load_extension(f"cogs.{filename[:-3]}") + +bot.run("MTA5ODk5MzExMjI5NjE5NDA3MA.GUj8WN.16iwjYtaouRXbsfJhCi1U7fa75ehLFb7YRbEnU")