discord.py

Deleting a bot's message in discord.py

自古美人都是妖i 提交于 2021-02-07 14:33:24
问题 I have already made all of the proper imports and I have tried looking for answers from other posts but it seems to not quite fit my issue. I am trying to randomly send a message, which I can do. However I can not seem to delete the messages after a certain cool down time. The cool down time is not the issue however. It is deleting the bots message. I know how to delete a user's message but I have very little idea on how I would delete the bots message. Any help would be nice. Here is my code

Discord.py how to invoke another command inside another one?

泄露秘密 提交于 2021-02-07 10:24:26
问题 I want my bot to play a specific song when typing +playtest using already defined function (+play) but i got an error says "Discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Command' object is not callable" an entire code work perfectly fine except for this command i wonder does ctx.invoke enable passing arguments? or i just missed something here is my brief code import discord import wavelink from discord.ext import commands import asyncio from bs4

Discord.py how to invoke another command inside another one?

坚强是说给别人听的谎言 提交于 2021-02-07 10:22:26
问题 I want my bot to play a specific song when typing +playtest using already defined function (+play) but i got an error says "Discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Command' object is not callable" an entire code work perfectly fine except for this command i wonder does ctx.invoke enable passing arguments? or i just missed something here is my brief code import discord import wavelink from discord.ext import commands import asyncio from bs4

Discord rich embed buttons

喜夏-厌秋 提交于 2021-02-07 09:45:36
问题 I made a few discord.py bots, but I came across one which was surprising. It's called IdleRPG and uses rich embed messages with buttons. Here's a pic (note the buttons at the bottom of the menu): I've tried contacting the developer and been searching the net but can't seem to find how they did it. Does anyone know of any resources on how to create them? Please provide links. 回答1: Update: Please check this answer for the latest version of discord.py . Here you go... I was able to create a

How to mention a sender of a command? discord.py

梦想的初衷 提交于 2021-02-05 11:50:24
问题 I created a super simple .report <person> command. I have it so it will be sent to a certain channel when someone types it. What I wanted to do is have it display the name of the user who reported the other user. I don't know how to go about doing that. Does anyone know the best way? @bot.command() async def report(*, message): await bot.delete(message) await bot.send_message(bot.get_channel("479177111030988810"), message) 回答1: You could do something like this, where you take the context (ctx

How to mention a sender of a command? discord.py

寵の児 提交于 2021-02-05 11:50:15
问题 I created a super simple .report <person> command. I have it so it will be sent to a certain channel when someone types it. What I wanted to do is have it display the name of the user who reported the other user. I don't know how to go about doing that. Does anyone know the best way? @bot.command() async def report(*, message): await bot.delete(message) await bot.send_message(bot.get_channel("479177111030988810"), message) 回答1: You could do something like this, where you take the context (ctx

AttributeError: 'Bot' object has no attribute 'add_roles'

那年仲夏 提交于 2021-02-05 11:29:35
问题 I am writing a bot for discord in Python. I want that when someone logged in to the server, he was given a certain role import discord from discord.ext import commands from discord.ext.commands import bot bot = commands.Bot(command_prefix='!') from discord.utils import get @bot.event async def on_member_join(member): role = get(member.roles, name="Игроки") await bot.add_roles(member, role) When I start and someone enters the server, I get the following error: AttributeError: 'Bot' object has

How to set a default using context with context defined in same line?

老子叫甜甜 提交于 2021-02-05 11:26:05
问题 I am creating a discord bot, and I am trying to make it where if a member says a command with no user mentioned, it defaults to themself. It doesn't work inline, and I need the arg in the same line. I tried to put the default in the same line, but I need the ctx for that, and ctx is defined in the same line, so it won't work. @bot.command(name="joined", description="Shows precisely when a member of the server joined", aliases=["entry", "jointime", "join_time"], pass_context=True) async def

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

discord.py | How do I check if the message being sent is being sent directly to the bot (DM) or in a chat?

﹥>﹥吖頭↗ 提交于 2021-02-05 10:57:05
问题 I want to check to see if the message being sent (on_message()) is in a DM sent to the bot or just sent in any other place like a chat in a guild. Any help would be greatly appreciated. @client.event async def on_message(message): if message type is dm: #do stuff elif message type is not dm: #do something else``` 回答1: You can check message.guild. @client.event async def on_message(message): if message.guild: # message is not DM # do stuff else: # message is DM # do something else``` 来源: https