A
A
Alexander Prokopenko2021-07-16 19:43:18
Python
Alexander Prokopenko, 2021-07-16 19:43:18

set_permissions not working in discord.py?

I am writing a discord bot in python, but when I try to create the mute command, I get an error.

here is my code:

from discord.ext import commands
from discord.ext.commads import has_permissions, MissingPermissions
import discord


class Mute(commands.Cog):
  def __init__(self, client):
    self.client = client


  @commands.command()
  @commands.has_perrmissions( mute_members = True)
  async def mute(self, ctx, *, member: discord.Member, reason = None):
    for i in ctx.guild.channels:
      channel = self.client.get_channel(i.id)
      await channel.set_permissions(member, reason = reason, send_messages = False, add_reactions = False, speak = False)

    


def setup(client):
  client.add_cog(Mute(client))


error:
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "D:\Python\Bots\Discord Bots\CasinoBot\module\commands\mute.py", line 2, in
from discord. ext.commads import has_permissions, MissingPermissions
ModuleNotFoundError: No module named 'discord.ext.commads'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\Python\Bots\Discord Bots \CasinoBot\main.py", line 28, in
client.load_extension( f'module.commands.{ filename[:-3] }' )
File "C:\Users\Acer\AppData\Local\Programs\Python\Python39 \lib\site-packages\discord\ext\commands\bot.py", line 678,in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Acer\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'module.commands.mute' raised an error: ModuleNotFoundError: No module named 'discord.ext.commads'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Guerro69, 2021-07-16
@Goverl

1. Why did you import commands separately from discord.ext and didn’t use it anywhere, then you re-import decorators along the same path from commands.
2. You have a grammatical error, instead of "discrod.ext.commands" you wrote "discord.ext.commADS", respectively, and an error occurs

ModuleNotFoundError: No module named 'discord.ext.commads'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question