Команда мут discord py
muterole = discord.utils.get(ctx.guild.roles, embed = discord.Embed(title='Мут', color=0xb3b3b3)
embed.add_field(name='Модератор', value=ctx.author.metion, inline=False)
embed.add_field(name='Нарушитель', value=member.Metion, inline=False)
embed.add_field(name='Причина', value=reason, inline=False)
embed.add_field(name='Время', value=time, inline=False)
await member.add_role(muterole)
await ctx.send(embed=embed, delete_after=10)
await asyncio.sleep(time * 60)
await member.remove_roles(muterole)
muterole = discord.utils.get(ctx.guild.roles, embed = discord.Embed(title='АнМут', color=0xb3b3b3)
embed.add_field(name='Модератор', value=ctx.author.metion, inline=False)
embed.add_field(name='Нарушитель', value=member.Metion, inline=False)
await member.remove_roles(muterole)
await ctx.send(embed=embed, delete_after=10)
embed = discord.Embed(title='Кик', color=0xb3b3b3)
embed.add_field(name='Модератор', value=ctx.author.metion, inline=False)
embed.add_field(name='Нарушитель', value=member.Metion, inline=False)
embed.add_field(name='Причина', value=reason, inline=False)
await member.kick(reason=reason)
await ctx.send(embed=embed, delete_after=10)
embed = discord.Embed(title='Бан', color=0xb3b3b3)
embed.add_field(name='Модератор', value=ctx.author.metion, inline=False)
embed.add_field(name='Нарушитель', value=member.Metion, inline=False)
embed.add_field(name='Причина', value=reason, inline=False)
embed.add_field(name='Время', value=time, inline=False)
await member.ban(time=, reason=)
await ctx.send(embed=embed, delete_after=10)
И еще подскажите еще как сделать типо внутреннюю роль у боти (!addmoder или! staffmode) для команд модера
1. У Embed значение Value должно быть в str. У тебя оно отражает другую модель пользователя в discord.py. Можно заменить на "<>".format(member.mention)
2. У тебя во всех таких Value написано metion, синтаксическая ошибка, бывает.
3. Попробуй в embed менять значения параметра color на colour, у меня иногда так тоже работало.
Для внутренней роли у бота можно сделать таким образом:
@bot.command(help = "Выдает модерку указанному пользователю")
@commands.has_permissions(administrator = True)
async def addmoder(ctx, member: discord.Member):
embed.set_author(name = member.name, icon_url = member.avatar_url)
embed.add_field(name = 'приветствуем в рядах модераторов', value = "<>".format(member.mention))
embed.set_footer(text = 'был назначен администратором <>'.format(ctx.author.name), icon_url = ctx.author.avatar_url)
I am here today asking a question on mute commands. I have been trying to find a tutorial but couldn't. Most videos or articles state that you need a role id but, I want to make it so if it creates a muted role in the server and then it keeps using the role it created. Sort of like Dyno's mute command. Is there a way to do that? Please let me know. Thanks!
2 Answers 2
Here I have made a simple way to create a role each time you use the mute command. You would need to create a role called Mute or whatever you want it to be with the role permissions prior setting it up. Otherwise, but a more extensive way would be to store the role id from the server in a database so you wouldn't have to create the role and the bot would only make it once, then apply the role, but it's something you can find out.
You can add extra precautions that the bot would check when a user uses the command, or who can use it; below the bot can check if the user has a lower role they are trying to mute, and checks if a member was provided to mute.
It's quite a basic example, but it's also good to attempt or leave some code that you have tried in your question. As this helps to understand what you want and more specifically or you have at least shown evidence.
So I made it that everytime bot joins a server, It creates a "Muted" role and stores it in a database i.e JSON file you can change it to a better storing system as you want.
So for database system, you need json module. Import it first where you are importing other modules i.e discord , discord.ext etc.
Then we will create a on_guild_join event that will fire when bot is added in a guild. In this event, we will create a role named "Muted" and for that role, we will disable the send_messages and add_reactions permissions so that anyone with that role cannot send messages nor add reactions.
Once we created the role we can get the role using it's name using utils from discord module.
Once we created the role we can get the role using it's name using utils from discord module.
Now, that we have Muted role setup we need to store it in our Database so we can get it when some calls the mute command, So create a new file in your working directory named muted_roles.json and in that file put curly braces like this: <> . Why we did that? Well JSON file needs curly braces and JSON module cannot manipulate those files that do not have those braces.
Then getting back to code, here comes the json module in the play.
Now when the bot will get a new guild, you will notice in your Json file that there's the guild ID with the role ID. Just like a Python Dictionary. Somewhat like this:
Now let's head over to the next step of making command;
. And mute command is done! Please read more about all the mentioned modules and other methods from given references it will help for better understanding.
Discord Mute Bot is a simple discord bot written in Python 3.8 that is designed to help muting an entire channel when playing Among Us in a voice channel.
- Install Python 3.8 and the psutil library using pip
- Clone this repository
- Create a file named SECRETS.py and enter your discord bot token and discord-id, i.e.
- Run Bot.py
- optional: change prefix and activity of the bot at the top of Bot.py
- Create voice channels "Crew" and "Ghosts" on your discord
- Create role named "Mute Master" on your discord
- .[mute|m] to mute all members currently connected to your voice chat.
- .[unmute|um|u] to unmute all members currently connected to your voice chat.
- .[status|ping|info|p] to get current information about the bot.
- .[help] (command) for help.
- .[config|cfg|settings] (Admins only) to change bot configuration for the guild. Settings include changing the role to mute, the channel names of the game and ghosts channel and wether server mute is suppressed or not.
- .[invite|i|inv] to get the invite code to add this bot to a guild.
- .[code|c|game|host] (skeld|mira|polus|airship) (eu|na|asia) to show a game code in a nice embed. You can use .config code-channel to only allow a certain channel for codes to be sent.
It also does the following in the background:
- People who join the voice chat while the game is running will automatically be muted.
- People who move to a "dead" channel will automatically be unmuted and muted again if they rejoin the game channel.
- People who are muted and join the game channel while mute is not active will be automatically unmuted.
- Other server mute actions performed by guild members will be suppressed. This is disabled per default, you can enable it with .config toggle
2 ответа
Здесь я сделал простой способ создавать роль каждый раз, когда вы используете команду отключения звука. Вам нужно будет создать роль под названием Mute или как вам угодно с разрешениями роли перед ее настройкой. В противном случае, но более обширным способом было бы сохранить идентификатор роли с сервера в базе данных, чтобы вам не пришлось создавать роль, и бот мог бы сделать это только один раз, а затем применить роль, но это то, что вы можете найти из.
Вы можете добавить дополнительные меры предосторожности, которые бот будет проверять, когда пользователь использует команду или кто может ее использовать; ниже бот может проверить, имеет ли пользователь более низкую роль, которую он пытается отключить, и проверяет, предоставлен ли участник для отключения звука.
Это довольно простой пример, но также хорошо попытаться или оставить код, который вы пробовали в своем вопросе. Так как это помогает понять, чего вы хотите, а точнее, или вы хотя бы представили доказательства.
Итак, я сделал так, что каждый раз, когда бот присоединяется к серверу, он создает "отключенную" роль и сохраняет ее в базе данных, то есть в файле JSON, вы можете изменить его на лучшую систему хранения по своему усмотрению.
Итак, для системы баз данных вам понадобится модуль json . Сначала импортируйте его туда, где вы импортируете другие модули, например discord , discord.ext и т. Д.
После того, как мы создали роль, мы можем получить роль, используя ее имя, используя utils из модуля discord .
Теперь, когда у нас настроена отключенная роль, нам нужно сохранить ее в нашей базе данных, чтобы мы могли получить ее, когда кто-то вызовет команду mute . Итак, создайте новый файл в своем рабочем каталоге с именем muted_roles.json и в нем file поставьте фигурные скобки следующим образом: <> . Почему мы это сделали? Что ж, файлу JSON нужны фигурные скобки, а модуль JSON не может манипулировать теми файлами, у которых нет этих фигурных скобок.
Затем, возвращаясь к коду, здесь идет модуль json в игре.
Теперь, когда бот получит новую гильдию, вы заметите в своем файле Json, что есть идентификатор гильдии с идентификатором роли. Прямо как словарь Python. Примерно так:
Теперь перейдем к следующему шагу создания команды;
. И команда отключения звука выполнена! Пожалуйста, прочтите больше обо всех упомянутых модулях и других методах из приведенных ссылок, это поможет лучше понять.
About
Discord Mute Bot is a simple discord bot written in Python 3.8 that is designed to help muting an entire channel when playing Among Us in a voice channel.
I am here today asking a question on mute commands. I have been trying to find a tutorial but couldn't. Most videos or articles state that you need a role id but, I want to make it so if it creates a muted role in the server and then it keeps using the role it created. Sort of like Dyno's mute command. Is there a way to do that? Please let me know. Thanks!
2 Answers 2
Here I have made a simple way to create a role each time you use the mute command. You would need to create a role called Mute or whatever you want it to be with the role permissions prior setting it up. Otherwise, but a more extensive way would be to store the role id from the server in a database so you wouldn't have to create the role and the bot would only make it once, then apply the role, but it's something you can find out.
You can add extra precautions that the bot would check when a user uses the command, or who can use it; below the bot can check if the user has a lower role they are trying to mute, and checks if a member was provided to mute.
It's quite a basic example, but it's also good to attempt or leave some code that you have tried in your question. As this helps to understand what you want and more specifically or you have at least shown evidence.
So I made it that everytime bot joins a server, It creates a "Muted" role and stores it in a database i.e JSON file you can change it to a better storing system as you want.
So for database system, you need json module. Import it first where you are importing other modules i.e discord , discord.ext etc.
Then we will create a on_guild_join event that will fire when bot is added in a guild. In this event, we will create a role named "Muted" and for that role, we will disable the send_messages and add_reactions permissions so that anyone with that role cannot send messages nor add reactions.
Once we created the role we can get the role using it's name using utils from discord module.
Once we created the role we can get the role using it's name using utils from discord module.
Now, that we have Muted role setup we need to store it in our Database so we can get it when some calls the mute command, So create a new file in your working directory named muted_roles.json and in that file put curly braces like this: <> . Why we did that? Well JSON file needs curly braces and JSON module cannot manipulate those files that do not have those braces.
Then getting back to code, here comes the json module in the play.
Now when the bot will get a new guild, you will notice in your Json file that there's the guild ID with the role ID. Just like a Python Dictionary. Somewhat like this:
Now let's head over to the next step of making command;
. And mute command is done! Please read more about all the mentioned modules and other methods from given references it will help for better understanding.
Я здесь сегодня задаю вопрос о командах отключения звука. Я пытался найти учебник, но не смог. В большинстве видеороликов или статей говорится, что вам нужен идентификатор роли, но я хочу сделать так, чтобы он создавал на сервере роль с отключенным звуком, а затем продолжал использовать созданную роль. Что-то вроде команды отключения звука Дино. Есть способ сделать это? Пожалуйста, дай мне знать. Спасибо!
Читайте также: