K
K
kramick2021-07-03 14:25:30
Python
kramick, 2021-07-03 14:25:30

How to solve bot permissions issue in discord py?

I decided to write a bot that changes the user's text from normal to bold in a discord group. The bot changes the text only for those users who have a certain role. The code works pretty well, but I ran into a bot rights issue . When creating the bot , I specified administrator rights, and also tried to create a role with administrator rights on the discord server itself, but all in vain . Below I have given the bot code, of course, without specifying imports and a token due to security. PS I did the test on my twink account

client = discord.Client()

list_roles = ['King', 'КОР ОЛЬ']    # список названий ролей

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))    # подключение бота

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    for role in list_roles:    # проверяем наличие роли пользователя в списке
        if get(message.author.roles, name=role):
            await message.edit(content='**' + str(message) + '**') # изменяем текст с формы message на **message**

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-03
@kramick

What the

bot rights problem
?
When it comes to editing posts, you can't edit other people's posts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question