discord.py-rewrite

Discord.py ctx.guild.edit works but not self.bot.guild.edit?

一笑奈何 提交于 2021-02-05 11:18:33
问题 Like the title says, I'm trying to do guild edits but on an events. Here's part of my code: @commands.guild_only() async def on_ready(self): server = self.bot.get_guild("serverid") while True: await self.bot.guild.edit(guild=server, name="foo") await asyncio.sleep(1) await self.bot.guild.edit(guild=server, name="bar") await asyncio.sleep(1) I've already tested it with a standalone command, so I know that ctx.guild.edit works but I'm not sure how to get it to work in an event. 回答1: You should

How to install discord.py-rewrite dependency on Heroku for Discord bot hosting?

戏子无情 提交于 2021-02-05 10:55:17
问题 I'm trying to deploy my discord.py bot on Heroku using my GitHub master branch, but have been unable to do because of a git error: Could not find a tag or branch 'rewrite', assuming commit . What do I need to do to successfully install the 'rewrite' dependency? I am currently using the files "requirements.txt", "runtime.txt", "Procfile" and "Aptfile". I've tried several combinations of dependencies in my requirements.txt file, including: git+https://github.com/Rapptz/discord.py@rewrite git

Sending message every minute in discord.py

巧了我就是萌 提交于 2021-02-05 09:44:44
问题 I am trying to make the bot send a message every minute in discord.py. I do acknowledge that this is a easy thing to do but I have tried multiple times but resulting with no luck. I have not gotten any error messages. Here is my code: import discord from discord.ext import tasks client = discord.Client() @tasks.loop(minutes=1) async def test(): channel = client.get_channel(CHANNEL_ID) channel.send("test") test.start() client.run(TOKEN) 回答1: You try to get channel with get_channel() , but your

Sending message every minute in discord.py

会有一股神秘感。 提交于 2021-02-05 09:44:07
问题 I am trying to make the bot send a message every minute in discord.py. I do acknowledge that this is a easy thing to do but I have tried multiple times but resulting with no luck. I have not gotten any error messages. Here is my code: import discord from discord.ext import tasks client = discord.Client() @tasks.loop(minutes=1) async def test(): channel = client.get_channel(CHANNEL_ID) channel.send("test") test.start() client.run(TOKEN) 回答1: You try to get channel with get_channel() , but your

How to get the member count in discord.py rewrite?

假如想象 提交于 2021-01-29 16:29:47
问题 I wanted to make an command to show the membercount but it doesnt work this is what i have: @bot.command(name='membercount') async def membercount(ctx): await ctx.send(len(guild.member_count)) and this is the error i get: Module 'discord.guild' has no 'member_count' member I tried searching on the internet but didnt find an working option. 回答1: Although Ron's example does work, it is not a very elegant way considering that ctx.guild.members is just a list, meaning you can use len() on it as

Retrieve list of members in channel discord.py rewrite

梦想的初衷 提交于 2021-01-29 13:50:22
问题 Summary I'm really new to discord.py and am trying to figure out how to retrieve a list of people in a discord server channel. I'm working on a command that would randomly separate the channel into two different calls, but I am wondering how I would retrieve the members in a voice channel, create a list of the members, randomly split them, and lastly move the members. My main concern right now is just retrieving a list of members into a list [] format this is what I have so far: async def

discord.py Error message whenever user dms bot

☆樱花仙子☆ 提交于 2021-01-29 10:36:52
问题 Using the code linked here, I had created a custom prefix for my bot a couple months ago. However, I ran into an issue when I was finally getting into DM responses. Due to the custom prefix, I have been receiving this error and traceback whenever someone dms my bot: Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\bagle\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 802, in get_prefix ret = list(ret) TypeError:

Discord.py-rewrite - How to make the BOT self mute or self deaf in a voice channel?

有些话、适合烂在心里 提交于 2021-01-29 08:30:45
问题 I am making a Discord BOT using discord.py-rewrite and am focusing on the Music part of my BOT. I checked the API several times but I do not know how to make my self mute or self deaf on a voice channel (not server mute or server deafen). Anyone please know how I can self mute or self deaf my discord BOT? 回答1: It looks like the API doesn't expose this functionality, but there is a method for doing this in the websocket code @bot.command() async def mute(ctx): voice_client = ctx.guild.voice

Discord.py Detect message in Embed Title or Description

旧时模样 提交于 2021-01-29 08:13:02
问题 I am currently trying to make an 'Anti Selfbot' Bot. I would like to do something good for the Discord Community. Therefore, I have tried to make an on_message event that can detect if an Embed contains 'selfbot', which would cause the message to get deleted and for the user to be banned. I have already begun making my bot. However, I am not sure how to read the content of an Embed. if 'selfbot' in message.content: # do some stuff here So, basically, the only problem I am having at the moment

Is there a way to find all the loaded and unloaded cogs in discord.py-rewrite

雨燕双飞 提交于 2021-01-29 06:59:45
问题 I have a lot of cogs for my bot, but i load and unload them using commands Still I get confused and load/unload a cog again-and-again I wonder is there a way to check all the loaded and unloaded cogs using commands.(Other than the default help command) 回答1: Looking at discord.py documentation, if you try to load a cog that is already loaded, it will raise a discord.ext.commands.ExtensionAlreadyLoaded exception. Using this error, you could do this: from discord import commands bot = commands