discord.py-rewrite

ModuleNotFoundError: No module named 'cogs'

百般思念 提交于 2021-01-27 22:00:09
问题 I wrote a discord bot that uses cogs. Here's my code for loading in each extension/cog: import discord import os from discord.ext import commands client = commands.Bot(command_prefix= '.') @client.command() async def load(ctx, extension): client.load_extension(f'cogs.{extension}') @client.command() async def unload(ctx, extension): client.unload_extension(f'cogs.{extension}') @client.command() async def reload(ctx, extension): client.unload_extension(f'cogs.{extension}') client.load_extension

How do you create a custom decorator for discord.py?

 ̄綄美尐妖づ 提交于 2021-01-25 06:54:53
问题 I am working on a bot. For a certain cog, I wish to create a custom check decorator that checks to see if the person running the command has a certain role. The role is stored as a role class as an instance variable. When I tried running it, it doesn't work. How do you make the decorator? class Moderation(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot self.mod_role = None # Assume there's already a role here class Decorator: @classmethod def requires_mod(cls, func):

Custom Emoji's and Animated Emoji's not working [discord.py-rewrite]

不羁岁月 提交于 2021-01-20 11:34:20
问题 I recently built a simple command to test the format of custom emoji's and animated emoji's Here is what the command was @bot.command() async def say(ctx, *, text): await ctx.send("<:ono:521148278079881219> You said %s" % text) But the output message didn't send the custom emoji, instead it messaged :ono: You said hello(the text i messaged in chat) Any help will be appreciated. 回答1: You can use Client.get_emoji to get the Emoji object, then use that to build your string @bot.command() async

Custom Emoji's and Animated Emoji's not working [discord.py-rewrite]

大城市里の小女人 提交于 2021-01-20 11:34:06
问题 I recently built a simple command to test the format of custom emoji's and animated emoji's Here is what the command was @bot.command() async def say(ctx, *, text): await ctx.send("<:ono:521148278079881219> You said %s" % text) But the output message didn't send the custom emoji, instead it messaged :ono: You said hello(the text i messaged in chat) Any help will be appreciated. 回答1: You can use Client.get_emoji to get the Emoji object, then use that to build your string @bot.command() async

Custom Emoji's and Animated Emoji's not working [discord.py-rewrite]

点点圈 提交于 2021-01-20 11:33:55
问题 I recently built a simple command to test the format of custom emoji's and animated emoji's Here is what the command was @bot.command() async def say(ctx, *, text): await ctx.send("<:ono:521148278079881219> You said %s" % text) But the output message didn't send the custom emoji, instead it messaged :ono: You said hello(the text i messaged in chat) Any help will be appreciated. 回答1: You can use Client.get_emoji to get the Emoji object, then use that to build your string @bot.command() async

Get a Discord Role by Id

牧云@^-^@ 提交于 2021-01-20 04:47:10
问题 I'm making a Discord bot but just ran into a problem. I want to modify a role. A specific role. I know how to do that with edit_role , but I need to get the Role object to edit it. Now, that's the problem. How do I get a Role object by the role's id ? Or can I use the id in the Role argument ? 回答1: You can use discord.utils.get to loop through Guild.roles and get the one you're looking for: from discord.utils import get role_id = 123 role = get(guild.roles, id=role_id) 回答2: You can simply use

Discord.py how do I make a mute command?

孤者浪人 提交于 2021-01-06 07:52:56
问题 As the title says. I'm trying to figure out how to make a mute command using discord.py rewrite. I'm thinking that we need to have a "mute" role where the command used gives the user the "mute" role and for how long. How do I achieve this. I already have @bot.command() @commands.has_permissions(mute_members) async def mute(ctx, member:discord.Member): 回答1: The best way to do this would be to have a database setup in which you can add and remove users. Then you can use the on_message event and

Discord Python Rewrite - Move channel

夙愿已清 提交于 2021-01-06 03:29:00
问题 Is it possible to move a channel on discord.py? Im making a nuke command that clones and deletes the channel, and it worked, but now i need to find out how to move the channel up to the origonal place, if there's a code / docs, please tell me a example. Thank's Edit: I Got a working edit but it's always drags it on top, i need it so it will drag the channel to the same position before it got nuked. My code that i currently have @client.command() @commands.has_permissions(manage_channels=True)

Discord Python Rewrite - Move channel

时光总嘲笑我的痴心妄想 提交于 2021-01-06 03:26:55
问题 Is it possible to move a channel on discord.py? Im making a nuke command that clones and deletes the channel, and it worked, but now i need to find out how to move the channel up to the origonal place, if there's a code / docs, please tell me a example. Thank's Edit: I Got a working edit but it's always drags it on top, i need it so it will drag the channel to the same position before it got nuked. My code that i currently have @client.command() @commands.has_permissions(manage_channels=True)

How do you have a Discord bot remove a user reaction to a message in discord.py?

旧巷老猫 提交于 2021-01-05 09:15:47
问题 I'm using an @client.event and using async def on_raw_reaction_add(payload): to read Discord reaction events. I need to be able to delete a user reaction when they fail one of the flags in my code. I saw in the documentation that there is await remove(user) but I don't think I'm using it right. Any suggestions? 回答1: You can use either Message.remove_reaction or Reaction.remove. A Reaction object represents a specific emoji reaction to a Message, so if the Reaction object you have is not for