#discord-bots
1 messages · Page 6 of 1
client = discord.Client for sure
PS C:\Users\Administrator\Desktop\Elongated Musket> & C:/Users/Administrator/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Administrator/Desktop/Elongated Musket/main.py"
Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\Elongated Musket\main.py", line 1, in <module>
import discord
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module>
from .client import Client
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module>
from .webhook import Webhook
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module>
from .async_ import *
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)
@slate swan I have no clue why
thats tge client
let me see your client =
client = discord.Client
it's discord.Client
maybe a corrupted installation and do you have another package that can cause name clashing?
i think it's disnake and pycord messing it up
so?
no no, its coming internally from discord.py
Now I get this
PS C:\Users\Administrator\Desktop\Elongated Musket> & C:/Users/Administrator/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Administrator/Desktop/Elongated Musket/main.py"
Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\Elongated Musket\main.py", line 2, in <module>
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
sed
this all worked when I tried running it on my PC, but on a vps it's not..
What's the issue?.
the same lol
@slate swan
@thorn grove for you the solution that clearly will work is to merge two of your on_message events into one
okay
seems like a corrupted installation or name clashing i cant really tell you would need to find out for yourself 😅
Ah
worked now
obligatory "use a venv for instsallations"
expectable
disappointing😔
theres a mispell

master32's stuff worked
epic
wow
@slate swan it's because I have discord.ext and discord.py installed locally

i guess... wtf is ctx.respond?
ctx.reply >
oh sorry
when someone deletes an image or an embed, how can i grab the image link and embed contents and send it inside an embed? for my audit log
gg
maybe store it on a variable
how can i fix it
use only msg?
yes
you should do frompy def func(m): boom(m) def func2(m1): beep(m1) def func3(m2): baap(m2) to
def func(m):
boom(m)
beep(m)
baap(m)```
make it one function
im pretty sure you just changed the argument to msg in every func
show code
okay
whats wrong lol
why do you need so many on_message
just remove second and third async def
noone knows
okay
I'm looking for a way to execute a function inside cog which prints something. Like a for loop for example. Just need an example
@commands.Cog.listener()
async def on_message_delete(self, message):
if not message.author.bot:
embed=nextcord.Embed(title="Message delete", description= f"Deleted by {message.author.mention} in {message.channel.mention}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())
fields=[("Content",message.content,False)]
for name, value, inline in fields:
embed.add_field(name=name,value=value,inline=inline)
for attachments in message:
file = await message.attachments[0].to_file()
file.filename = 'image.png'
embed.set_image(url='attachment://image.png')
await self.bot.get_channel(933978399280599080).send( embed=embed)
await self.bot.get_channel(933978399280599080).send( embed=embed)
could someone help me? im trying to have my bot send deleted images to a log channel
np
class Economy(commands.Cog):
...
async def withdraw_money(self, member, money):
# implementation here
...
async def deposit_money(self, member, money):
# implementation here
...
class Gambling(commands.Cog):
def __init__(self, bot):
self.bot = bot
def coinflip(self):
return random.randint(0, 1)
@commands.command()
async def gamble(self, ctx, money: int):
"""Gambles some money."""
economy = self.bot.get_cog('Economy')
if economy is not None:
await economy.withdraw_money(ctx.author, money)
if self.coinflip() == 1:
await economy.deposit_money(ctx.author, money * 1.5)
depends on WHEN do you want to print it
For example in there I want that coinflip function to be called like it prints ("hello")
Post_init
Missing just syntax
Apparently this is wrong
Yea the example is just bad lemme explain further
I'm about to get a value from database and store it inside a variable, and this needs to execute somewhere in code but it might need a for loop
Not sure if I can put for loops inside init can I
How about a while?
why not?
If it ok then nothing lol thought it somehow gives tons of load
if it is not infinite
like the text?
yesh lol
If it is?
text or link
message.content your Bot require Message.Content intent enabled
^^
I don't think it's a good idea
i guess that intent is called somehow different but ok
Wouldn't that be done in a function then past init
then your cog is probably not going to start
My prob is like own kind
function doesnt help with infinite loops
The database has a time value set like 13:00:00
I have a loop in other cog which check the time each second from File atm
Anyone know how to have discord.ext and discord.py installed without them clashing?
The solution could be like check the database each minute, if the time set has changed there
well that's more a task than a loop
Well yes
that's even more like a task
Ok gotta do it that way. Gotta store the time string into variable
Is it possible to do multiple tasks in same cog?
discord.ext is part of discord.py
why not?
You tell me haha. think someone told me multiple tasks in same cog don't work or something
Maybe it's the code I use
what's the difference between discord and discord.py? and would they cause any issues if both were installed locally
@tasks.loop(seconds=1)
async def called_once_a_day(self):
self.target_channel = self.bot.get_channel(self.discordchannelid)
x = datetime.datetime.utcnow()
y = (x.strftime("%H:%M:%S"))
z = open("postingtime.txt", "r").read()
if y == z.strip():
randness = collection.aggregate([{'$sample': {'size': 1 }}])
async for result in randness:
print("Requested random post from database:", result["motd"])
embed = discord.Embed(description=f"```yaml\nMessage of the day:\n{result['motd']}\n```", color=discord.Color.blue())
await self.target_channel.send(embed=embed)
@called_once_a_day.before_loop
async def before(self):
await self.bot.wait_until_ready()
print("Finished waiting")```
The yaml there is just decorating the embed
and the problem?
doing pip install discord you're installing discord.py
If you're referring to the pypi packages, discord points to an old version of discord.py
how can i make a embed instead of message
yeah I was, I'm getting this error for some reason
File "c:\Users\Administrator\Desktop\Elongated Musket\main.py", line 2, in <module>
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
discord.Embed()
There isn't any. Doublechecking this spaghetti might actaully work
But ok thanks for this
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
Do you have any third party libraries you're using alongside discord.py for things like slash command support
thanks
disnake, and pycord
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
there are multiple methods
Yeah you should probably get rid of them
i sent discord.Embed, there is everything
I need them for other projects though
btw it's called MESSAGE_CONTENT
idk how sadly
do i put msg.channel.send.embed?
!d poetry
No documentation found for the requested symbol.
!!
msg.channel.send(embed=embed)
Check out it's documentation there'll be a guide
await channel.send(embed=embed)
# or
await ctx.send(embed=embed)
# there are also other ways to send a message, just check the docs
where the second embed it's the name of your variable that is storing your discord.Embed object
i defined the varibles above
How is the line 7 in taht file
are you getting any errors
also that's not related with discord.py or discord Bots
how to change footer, description etc.
doesn't work
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
embed = discord.Embed(title=...,....)
embed = discord.Embed(title="Embed title field", description="Embed description field")
await msg.channel.send(embed=embed)
@thorn grove
oh
guys do anyone know how can i fix this ?
i already installed it but i dont know whats the problem.
how i make the title show the msg.author?
title=f"{msg.author}"
okay
where i put that?
after discord.Embed
replace the previous title= part with that
okay
top kek, also isnt tasks like not part of discord
just import from discord alone, and import tasks on a new line
Bot not workint
it dose not work
@slate swan
the bot not online
import discord
from discord import commands
import tasks
?
doesnt work
do you have bot.run with the api key and all
yeah let me send screen shot
its in heroku but yeah
error?
it works, but when i put the code no work
from discord.ext
what do you mean?
it worked earlier when i didnt put that code
but when i put it it doenst now
okay
at the end of get messages you need to have
await bot.process_commands(message)
You have to respond within 3 seconds of receiving an interaction
whats that
so that it knows to run the message through all the commands
put it at the end and dont return or anything
that return may be throwing it off
okay
when you use on_message you are overwriting the default that already runs the message through the commands
so you need to do it yourself with that line i sent
guys do anyone know how can i fix this ?
i already installed it but i dont know whats the problem.
I think you should learn a little bit more python before attempting to make a discord bot.
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!d discord.InteractionResponse
class discord.InteractionResponse```
Represents a Discord interaction response.
This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").
New in version 2.0.
i know the basics
error
install discord.py with pip
the stuff you need help on is pretty basic..
i already installed it
on discord.py
discord alone?
what is that code above line 10?
what do you mean ?
what's the value of msg at line 10?
pip install discord
yeah both pip install discord and pip install discord.py
no i know but i cant see why the error is happening
i got the same text when i installed both
block = ["text", "text"]
should i uninstall one of theme ?
yee
msg is only defined in get_messages
which one ?
you need to put it in there
ok wait
⚠ warning, also there no msg here
1984
pp is blocked 😭
discord.py has a support for tasks
okay i get it
yeah its a bad word
msg.author is dependent on the message
oh, how do i fix it?
and you dont have it unless it is in get_messages
Fixed thanks
so its working rn?
you need to put the part where you define the embed before the line that sends the embed
yeah thanks for your help :D
after the check that its a bad word
no problem
yeah its before i send the embed
yes but you need to put it RIGHT BEFORE
like the exact line before it
msg is only defined every time someone sends a message, right?
and you need the message to define whats in the embed properly
(to get the person who send the message)
okay
no other issues i see
tysm!
i like this community, so great
it worked 😊
or if you mean like you in specific like a user
@client.command()
@commands.is_owner()
async def do_stuff
this only works for the owner of the bot
if its a mod or owner role then:
if "Moderator" not in str(msg.author.roles) and(other stuff) \\do stuff here
oh well yeah that works then
it seemed like the owner of the server is what i though
thats something like guild_owner i cant remember
ah
well either way you can go if str(ctx.author) == "botowner68#3834":
and you can switch out the discord user for whoever
nah lol
discord.Embed=(do_stuff_here, color=0xHEXCODEHERE)
okay
https://github.com/sprmcell/spbot/blob/main/spbot/soy/commands.py probably somewhere here
ye here
yep
that
this is basically everything on embeds if you need
by default its transparent i think
im making a timeout cmd but it doesnt work anyone know how to fix it?
@commands.command()
async def timeout(self,ctx, member : discord.Member,*, time: datetime,reason:None):
for i in range(time):
await member.timeout(time)
await ctx.send (f'{member.mention} has been timeouted for {time},Reason = {reason}')
lemme send the code
well its 3:30 it seems like a good time to go to bed
bruh?
@latent anchor
async def timeout_user(*, user_id: int, guild_id: int, until):
headers = {"Authorization": f"Bot {client.http.token}"}
url = f"https://discord.com/api/v9/guilds/{guild_id}/members/{user_id}"
timeout = (datetime.datetime.utcnow() + datetime.timedelta(minutes=until)).isoformat()
json = {'communication_disabled_until': timeout}
async with client.session.patch(url, json=json, headers=headers) as session:
if session.status in range(200, 299):
return True
return False
then
@client.command()
@commands.has_permissions(kick_members=True)
async def timeout(ctx: commands.Context, member: discord.Member, until: int):
handshake = await timeout_user(user_id=member.id, guild_id=ctx.guild.id, until=until)
if handshake:
return await ctx.send(f"Successfully timed out user for {until} minutes.")
await ctx.send("Something went wrong")
unless the jewpi is updated
is this the stack overflow one?
ty ima try it
you mean colour
thought u were MURICAN
i now see ir
i forgor to put close parenthesis in description
this has embed things in it but i really gotta sleep
okay thanks for your help
@slate swan it didnt work and no error comes out
is ur bot admin
yes
have u tried timing out a normal user
yes
hm
hm
Hi
i changed sometime and it showed something went wrong
what does handshake means in the code
yes i want to work for discord, thank you
connected to api
v9
@latent anchor are u using cogs and self?
im using main.py only
not cogs
Why are you trying to iterate over a datetime.datetime object?
its above the command
ImportError: cannot import name 'ui' from 'discord' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/init.py)
what to do
show me whole code
Which version of discord?
update python and discord
discord or discord.py
u want all the main.py or the one u gave me
sure whole main.py
.ui extension isn't available in discord.py on pypi you need to install master version of discord from GitHub.
Hey @latent anchor!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
uh
link?
Hey @latent anchor!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
think u need to import json
so just pip install -U discord.py?
i am using 2.0 already
its still not working and i have json files in the json folder
No
pip install -U git+https://github.com/Rapptz/discord.py
Did you do this before?
i used nextcord lemme try and find the stackoverflow
You don't need to do all that. Your previous code was fine, but why are you iterating over time?
yeah i already have v 2.0
it couldnt be done like that?
@latent anchor ah so at the top where u define ur bot make it look like this kinda
warnings.filterwarnings("ignore", category=DeprecationWarning)
intents = discord.Intents().all()
client = commands.Bot(command_prefix="whatever", intents=intents, case_insensitive=True)
client.session = aiohttp.ClientSession()
k ive done that
then u can just do from discord.ui import whatever u want here
asyncio.sleep(100000) is kinda funny
!d discord.ext.tasks.loop use this (examples are on top of doc page)
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Also you can put these into one dict of type dict[author_id, Message object]
"Examples are on top of doc page"
You make a function
How can you await function definition
Did you even check the examples
It's a decorator
Did you install it
oh the discord hosting site it wont allow me to run my own commands through their console
i tried doing pip install discord.py through my source but that didnt work
What site
pebblehosting
way way too much its like 16 usd and in my currency thats 3 times lol but ill get it figured out
is this the same site or a different one
Different ones
Galaxygate offers a decent VPS with almost unlimited bandwidth for 3$/mo and I once used it myself, was enough to run like 4 bots in parallel
do they offer mySQL?
They offer you a literal server with full access to it, you can install whatever you want to it
And mysql installation is done in 3 commands from what I just googled
I like the look of that pebblehosting, there dedicated hosting is pretty cheap! 🤣😂 I can say most small cloud hosting does the same price as pebble host there usually started around 3$, I use digital ocean for my bot.
Hello, yesterday my discord module was working fine but now it seems like it is gone or something like it isn't there anymore because now it says import error
i did not change anything
What IDE is this
vscode
Check the python interpreter setting in bottom right corner
someone pointed out it could be a version thing
And tell me if you do have venv folder somewhere in your project
I recommend downloading normal python
i don't
Yeah just download normal python from normal python's site and select "Add Python to PATH" checkmark when installing
Make sure to delete windows store version before you install one from python site
i seem to be able to select a different version on that button, i have selected the 3.9 one and that one seems to work
Is it windows store too
yeah,
Personally I don't recommend it, sometimes there are bugs
That get solved by installing normal python
i am mostly just using it for a quick thing i generally don't really use python a lot so i don't mind
I am just making a small extra thing for an existing bot
Ok

How can i download a users profile picture in discord.py?
!d discord.User.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the avatar the user has.
If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.display_avatar "discord.User.display_avatar").
Asset has a save method
Thx
Why is my embed so wide?
because discord thought it was the right size for the content in the embed
Ok lol because it is by every embed my bot is sending now?
Make inline fields it will look fine
guys you kn a solu for this ??
seems to be a permission issue
and what should i do ?
i dont know what ur code is
your bot probably don't have access to the channel
nop same problem
ah i was wrong with id server thx
what about this
can i do custom buttons in my bot's profile?
You need to show the full error at the bottom as well if you want effective help, not cut out the most important part.
im at a lose, this worked months ago and now its not
how do i get the channel object from just the channel id since i have a task loop to change a specific channel name, the code attached doesnt work properly and returns a none object
Should I need to learn complete python to build a DC bot or just start by watching videos "How to build DC bot.." @trail flower
The YT videos teach you the wrong ways to do everything, they're also outdated and put you into tutorial hell when you have no prior experience with Py
Hello, i want to check if a message exists when my cog is in the initialize function
I would like to use this to make sure to unlock a channel if it is gone
I know the channel id and message id
first python pls
.d bot.guild
is it possible to link a .py file to another .py file?
How can we make slash command sync fast in servers?
Syncing is handled by discord itself so you can't really control that in any way
Discord needs some time to sync the commands to all the guilds, which iirc is max ~3 hours
You mean imports? #python-discussion or #❓|how-to-get-help
Learn Python first before even jumping to discord bots. Start with simpler projects first. You can use youtube/google to learn python though. There are plenty of good channels to teach you, but is not the case for discord bots. Most of those videos just write the code without any proper explanation (which you probably don't even need if you know enough py).
An option's name you set for the command isn't valid or at least not allowed to be set as option's name by discord
Check the channel id. If it's correct you probably started your tasks before the cache was ready
ty, it was exactly that
async def addMember(interaction, member: discord.member, role:str):
await interaction(member), interaction(role)
Addmember = addMember(wks, member, role)
im trying to do double user inputs but cant seem to get it right
ive debugged for the google sheets part already it checked out just porting to discord is a problem
why would you do interaction(member) and interaction(role) in the first place
im not sure whats the correct one
tried finding documentation but they werent the ones im looking for
so i just tried the most logical inpuit
hello Ashley
that's not how you use that 
you should remove that line and have the correct typehints, which are - member: discord.Member, role: discord.Role
so that, member gets converted to a Member object (converted by discord.py internally)
and role gets converted to a Role object (converted by discord.py internally)
Asher 
oh so just replace the interaction(member) with interaction(discord.Member)?
and same as role?
i mean another project file
in the function parameter definition
also isn't in await member.add_roles()?
and removing means removing the line, not modifying it
why call resursive
oh im not adding roles to discord itself
im trying to add it into a google sheet
like a user input role as member/staff
anyone?
it doesn't change the fact u are calling the same function in the function with no checks?
sorry i dont really understand this
I agree, asher should elaborate about the type of checks (I understand it though)
just copy paste all the code in that py file and place it in ur directory simplest way
im sorry i just started dabbling in this a few days ago so i dont understand some stuff still
u know what's a recursive function?
not really
so can u tell me why are u calling addMember in the addMember function what are u expecting to happen
i read it a bit is it something that calls upon another function after an input in a function
what if i want it in another oy file
im expecting something like /addMember <Member Name> <Member Role>
i keep getting this error "Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "info" is not found" however I'm able to use the command without issues, ill post my code in a pastebin (https://pastebin.com/9CJc3aKm). I'm able to use all the commands without issues I just get this error for all the commands I use.
the member name can obtained from the member list in guild, but i would like to put member role as an input]
I have the following folder structure:
application
├── app
│ └── folder
│ └── file.py
└── app2
└── some_folder
└── some_file.py
From inside in some_file.py, how do I import a
okay thanks
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
if (message.content.includes('@'))
return message.channel.send("You do not have permission");
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)
File "main.py", line 100
if (message.content.includes('@'))
^
SyntaxError: invalid syntax
how can i fix this?
!!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
if '@' in message:
return await message.channel.send("You do not have permission")
embed=discord.Embed(title='IDK', description=message)
await ctx.message.delete()
await ctx.send(embed=embed)
asher is there any way to do double user input for a bot command?
i cant seem to find any documentation online for it
average spoonfeeder without typehint for ctx 
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'content'
lmao
um is someone there?
oke wait
you probably did message = "some_str" then trying to do message.content
@commands.is_owner()
async def say(ctx, *, message):
if '@' in message.content():
return await message.channel.send("You do not have permission")
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)```
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
if '@' in message.content():
return await message.channel.send("You do not have permission")
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)```
not message.content, message is a string not a Message object
so how do i fix this?
if "@" in message:
.content too
I think you can see that by yourself too
no offence
i did but it says this
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'channel'
do u guys know how to make a backup of a server?
ctx.channel not message.channel smh, I just told you that message is a string not a Message object
oke
Can any one help me how can I add a role with a bot in python
how to add buttons in my message? some tuts are outdated
they were never decent tuts or even tuts in the first place
If you want Discord Button Roles in your discord server be sure to watch this video! Since Discord introduced buttons to the platform, more and more users have started to use them. They are a replacement from the old reaction roles and it gives an cleaner more modern look to your discord server. In this video you will learn how you can add some ...
yep thats right
@bot.command()
async def test(ctx):
view = View(timeout=60)
button = discord.Button(label="press me")
async def callback(interaction):
await interaction.response.send_message(f'{interaction.user} pressed me')
button.callback = callback
view.add_item(button)
await ctx.send('test', view=view)
thanks
thanks too
Np
this is such a great community
Can any one help me
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
How can I make the bot add a role
Thx
But how do I setup it
Am working on a nuke bot that's why
cant help, sorry
..? #bot-commands
Why?
bro?
lmfao
<@&831776746206265384>
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
we're not going to help you with that project
scofflaw fast af 😔
Sorry I didn't know
I’m back here again 😔
i mean like lmfao if u hadnt said nuke i was gonna send the code
the code works but how can i make the bot reply to the message that has the @
didnt like the dpy server or what? 
Am new in python
wha?-
every message?
ctx.reply
nvm 
no only in the message that has mention
R.i.p bro
if “@“ in msg.content ig?
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
if '@' in message:
return await ctx.send("You do not have permission")
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)```
thats the code
await ctx.reply(embed=embed)
ctx.reply smh
bruh in the message that says you do not have permission
then dew it there
dont act so dumb no offence
What are you trying to do 💀
Are you the owner of the bot?
Remove the if “@“ in message:
And tell what you are trying to do
i want the bot to reply
yea
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
bruh i know how to mention someone im not f stupid
thanks for the help tho
Well this doesn't mention anyone
This returns a list of people that got mentioned inside the message.
ctx.reply
thanks
i need help . i trying to make reaction roles but i have syntax error
@bot.event
async def on_raw_reaction_add(payload):
if message_id == 1001813362189021286:
guild_id = payload.guild_id
guild = discord.ulits.find(lambada g : g.id == guild_id, client.guilds)
if payload.emoji.name == 'statue_of_liberty':
print('Test')
but this
guild = discord.ulits.find(lambada g : g.id == guild_id, client.guilds)
^
SyntaxError: invalid syntax
its lambda
And utils not ulits
thx xd
Did you define what client is?
Give commands.Bot a variable
Client isn't defined plus no decorator on foo
Bro idk what u sayin
bot=true is depricated
You are trying to run the bot without defining what “client” is
So what should I do
Give a variable to commands.Bot
I swear to my good I don't know what to do
Hey @glacial jungle! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Use this ^ @glacial jungle
Kk
And remove your bot’s token from it
thx but now when i put reaction nothing happen
@bot.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 1001813362189021286:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
if payload.emoji.name == 'statue_of_liberty':
print('Test')
Nothing prints?
yeah
bro i have it
And there’s no decorator before foo as pandabweer said
I’m saying this to ! $IGMA#6749
UwU 
no
idk \
Ashley’s here
from discord.ext import commands
import discord
bot = commands.Bot(command_prefix="uwu", intents=discord.Intents.default())
bot.run("token")

"uwu" 💀
xd
Pandabweer be typing an essay
uwu help
not here 💀
The UwU bot
uwuhelp - show this message
Don’t think they are ever going to reply to this
💀
uwu
Oh nvm
Still
oh my-
Am stupid ik ik
b r u h
Am not good at python am a newbie
bot = commands.Bot(command_prefix="!!", intents=discord.Intents.all(), help_command=None)
get your bot token from dev portal and paste it in "
secret" also remove the secret
@glacial jungle ^
Pandabweer 
and you must put it up
They didn’t define bot correctly
btw
Imagine defining a bot without prefix 💀
Still
I did a prefix
can anyone help?
Change your token sir
XD
CHANGE IT FAST
REMOVE THAT IMG
LMAO
I think I'll create a walkthrough for setting up a basic bot if there still isn't one yet 
It's not a real toke
DELETE THATTTTTTTTT
oh
True true
i have screen xd
import asyncio
from discord import Intents
from discord.ext.commands import Bot, Context
class BasicBot(Bot):
def __init__(self) -> None:
super().__init__(
intents=Intents.all(),
command_prefix="!",
help_command=None
)
async def on_ready(self) -> None:
print("Ready")
bot = BasicBot()
@bot.command(name="test")
async def foo(ctx: Context) -> None:
await ctx.send("Hello!")
async def main() -> None:
async with client:
await client.start("token")
if __name__ == "__main__":
asyncio.run(main())
``` there you go a simple bot
XD
And make it a stickied message here
Bro got the entire server stressed 😭 😭
Lmao ik
nvm, just as I thought about the work I'll have to do 💀 dropped the idea in under 10 seconds 
ong
true af
Just do some imports
Define the bot
Make a ping command
Run the bot
can anybody help?
That’s it ezy tutorial
would be pointless, if I have to make one, might as well make a good one 
You basically only need a database.
Make one with 2100 lines in main file
pls learn python
Like me 💀
900 lines here
Am already learning ik
🗿💀
I have cogs
But I don’t use em
@bot.command()
@commands.is_owner()
async def say(ctx, *, message):
embed=discord.Embed (title= "**You dont have the permission to mention someone**")
if '@' in message:
return await ctx.reply(embed=embed)
await ctx.message.delete()
embed=discord.Embed (title= message)
await ctx.message.delete()
await ctx.send(embed=embed)``` how can i make the bot delete the message that has a mention on it?
cogs are for noobs
Please State Your Pending Orders, Your Highness
Sure every project can be done in one file.
Tf do I do now
imagine not putting everything in one file
I told you to remove if “a” in message:
Lol
with discord.py buttons, how should you get the person who clicked the button, as a member?
@bot.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 1001813362189021286:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
if payload.emoji.name == 'statue_of_liberty':
print('Test')
my code don't print
without error
Intendation
Tf is this
yea but then it wont work
wha-
what is happening and why is everyone getting indentation errors
Only 1 user got intendation error rn 💀
hi okimii
“Everyone”
big balls
Can u fucking help me
???????
Joe mama
😭 😭
hi Elias👋
GO WATCH A TUT OR SOMTH
Tf
async def button_cb(self, inter: discord.Interaction, button: discord.ui.Button):
member = inter.user if isinstance(inter.user, discord.Member) else (inter.client.get_member(inter.user.id) or await inter.client.fetch_member(inter.user.id))

lmao
So why did I joined this server dumbo
ashley what the hell
I NEEED HELPPP
oh my
once a wise human told me not to use client
Im sorry bro but idk

but why not?
Idk
..thanks
I mean we can name the variable anything
Bot gives you everything that Client does, plus the command extension
esoteric code go brrrr
welcome
Client would be for very simple polling or something
Honestly I don't know why you would want it
i mean i'll probably not use it but thanks
stating the obv as usual
pov ashley after bully this emoji 😎
We can name it whatever we want
It’s just that bot feels good
Dk why 💀
Oh, I thought they meant the difference between Client and Bot
idgaf what you name it. Call it self if you are evil enough
💀
well, I just wanted to get/fetch a member
and I didnt specify and bot instance so I used the interaction's client, soooooooo
it was just an example
I’ll call it Ashley in my next bot
cok
forgib me for my sins instead
80085
huh
reads like boobs to me
It is
giggity
quagmire
(.) (.) boobs
What the fuck is this channel right now
balls
ikr😭
Some humans chilling
😭
lmao
u mis-spelled ban 😔
😭
Lets get back to the channel topic and follow the #code-of-conduct
cok
guy made the entire channel stressed
wrong reply, fm
u miss spelled i love okimii😔
Waiting for them to give another error

!mute 836928474081525760 6h take a break and re-read the #code-of-conduct
:incoming_envelope: :ok_hand: applied mute to @novel prairie until <t:1658957870:f> (5 hours and 59 minutes).
!mute 981627297993998379 6h take a break and re-read the code-of-conduct
:incoming_envelope: :ok_hand: applied mute to @glacial jungle until <t:1658957883:f> (5 hours and 59 minutes).
💀 ** **
Hmm anyways
that wasn't for ur msg 😅
ok
i has a question,what command should i add for my bot like im running out of ideas

Reminder?
look up some random api, and do something with it
hmm sure i'll try that
What's the purpose of your bot?
okiki
Oh hi robin
The world does not need any more multi-purpose bots haha
simple & expandable bot core infrastructure 🙂
oh well its name stands for "all in one"
or all in one purpose
oof. Alright. Do you have autorole?
Then make some commands for a bot probably
That is usually a very highly requested feature
I have one in my bot for dm bot
Like if someone joins a guild it gives them the members role?
A role of the admin's choosing yes
Any role the user sets
and perhaps multiple roles
Or a verification system
Oohh ok ok
Sure,thankss!
verification systems are lame. Discord is going to do this out-of-the-box soon enough. Not worth the effort
Okayy thank you too!
Oh damn
Then go with economy
Hmm i'll try that too!(im not gonna make it out alive)
Good luck
Thx thx
If you are truly bored go on fiverr and make some bots for others
the pay is absolutely crap though
We have a pretty simple one, python-discord/botcore
Or go touch grass if you haven’t
Oh thats a pretty good idea or suggestion,might as well earn some money,thanks!
whats grass
some green substance found on earth*
interesting
oh its a liquid
will do,,thxx

Oh and also if im gonna separate my bots commands to another file,how can i do that without rewriting it into cogs ?
You can put each command as @commands.command() instead of @bot.command() and then bot.add_command in the setup function
Oohh okk thanks i'll try that tommorow :)
are buttons in dpy 2?
yes
link doc plz
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
cheers
either surround each parameter with " " during command usage or have * after the first non-multi-argument parameter
or have it with 1 parameter and use split with a comma or something
hi i need payload and member
@bot.event
async def on_member_join(member, *, payload):
member= payload.member
guild = member.guild
role = discord.utils.get(guild.roles, name='Člen')
await member.add_roles(role)
TypeError: on_member_join() missing 1 required keyword-only argument: 'payload'
Hey, i need some help with the ban. Im using @client.event in on_message() and my code wont work. Here is it: ```py
if message.content.startswith("&ban"):
banargs = message.content.split(" ")
if len(banargs) == 1:
await message.channel.send("Gib einen User ein!")
if len(banargs) == 2:
member: Member = discord.utils.find(lambda m: args[1] in m.name, message.guild.members)
await member.ban()
That event only provides you with a member object
but i need payload
You should be using commands for this, and it should be no more than 2 lines
Why?
member= payload.member
guild = member.guild
oh
burh
i need study docs
@bot.event
async def on_member_join(member):
guild = member.guild
role = discord.utils.get(guild.roles, name='Člen')
await member.add_roles(role
Always a good idea
so like this
You’re missing the last closing parenthesis but yeah
Like That: py @client.commands async def ban(ctx, member: discord.Member): await member.ban()
?
(reason=reason) would work
If you have the reason param
Discord has a built-in ban command fyi
@client.command()
Thanks
With a few issues, yes
almost every user here knows this

People still implement their own for some reason
yuh
You can use reason inside .ban()
Why just make an embed to show the reason
Without actually using it
Before you start, don’t use discord-py-slash-commands or any of those
I’m guessing you may have done a YouTube or google search and that’s what pops up
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias```. There is no help command but there seems to be
Discord.py has a default help command
how do i delete it
!d discord.ext.commands.Bot.remove_command
remove_command(name, /)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
Changed in version 2.0: `name` parameter is now positional-only.
ty
i need to stop command when is seconds none.
@bot.command()
async def slowmode(ctx, seconds: int=None):
if seconds == None:
embed= discord.Embed(title='Error', description='Použí `!!slowmode <sekudy na spomalení>`', color =0x552E12)
await ctx.send(embed=embed)
await ctx.channel.edit(slowmode_delay=seconds)
await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")
can anybody help?
this does not work?
it is
so what's the problem?
👀
ohh you can do return await ctx.send.... in the first condition
or write an else block
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
!d discord.PublicFlags.all
No documentation found for the requested symbol.
property public_flags```
Equivalent to [`User.public_flags`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.public_flags "discord.User.public_flags")
in the ban command, how do I see if the bot role is above that of the person I want to ban?
You can assume that the bot role is above you're trying to ban, and in the case that it isn't, catch the discord.Forbidden error
the problem is that it is not giving that error
the bot sends the message that the person was banned even though they were not
It'd be helpful to see any current code
I understand why it wasn't giving the error. The bot didn't have the code to banish, just to send the message
my bad
Evening all, sorry i am back 😄 I was wondering if anyone can help as I have pretty much brain farted now, https://paste.pythondiscord.com/cobagayila
in my on_raw_reaction_add, I thought with it being a user event, it would need to start of with payload.user_id but I thought wrong and not sure how I am even suppose to start this thing off. I have read over the docs, and didn't think I would need anything else but seem to be wrong; https://discordpy.readthedocs.io/en/stable/api.html?highlight=payload#discord.RawReactionActionEvent,
I usually add in print with some jibberish in to make sure it goes to each step or let me traceback tell me if anything is wrong, but neither are working so yeh I feel as though I'm just not doing the basics right
Okay, first things first.. is it sending the embed and reacting with all the emojis from game_roles?
Yeah
Cool so the command works, I'm guessing the event is what's not working?
Yep, well more like I just dont know how to start it anymore, i must have tried so many different ways now and thought in the end with it being a user event, the only payload attribute i need is uder_id
The easiest way would be to check if str(payload.emoji) in game_roles, and if so, give them that role
So:
if game_roles.get(str(payload.emoji)):
role = game_roles.get(str(payload.emoji))
# give the member the `role` role
And this is why getting a second pair of eyes on things is always a good thing in the tech/dev world, I'll give it a whirl and see how I get thank you so much.
Yup. Also keep in mind this approach would give the user a role if they reacted with the right emoji on any message. You'll want to add an if statement that checks if the message the reaction is coming from is the same one you sent in your ReactionRoles command. This should be pretty easy, though, so leave it for the end
Enable presences intent and check for CustomActivity in member.activities
Roger, I'll take a note and have a read up on that tool. Thank you very much 🙂
No problem. Feel free to ping me with any follow up questions you may have
you can pass in a datetime object to the function and the style desired
from datetime import datetime, timedelta
ft_time = discord.utils.format_dt(datetime.now() + timedelta(minutes=42))
just copy your playlist and play it with any m.bot
yep
soooooo any solu
Is it CompanyeName or CompanyName? The error is obvious, it can't find the file/directory your looking for.
ah i named it CompanyeName
nop
Whats the full path to your bot main file? Can you grab it as text, not an image?
the slashes have to be from right to left
no problem, you'll get a unicode escape error😅
How do you learn to how to make a discord bot with discord.py?
You can just put it into a variable then put the variable into string
Although using absolute paths for project will make it break after renaming some parent folder or moving to other machine
So use relative 😉 👌
Just create good project structure
He's having issues with adding python to PATH?
Then what
Show your project files structure please
!ytdl @proven shale we don't help with anything related to it
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
can i dm you?
I'm trying to make a discord bot that web scrapes a random Wikipedia article, but after you try it once, it repeats the same thing
My code:
#Importing
import requests
import webbrowser
from bs4 import BeautifulSoup
import discord
import random
#-----------------------------
#Var's
TOKEN = '#Not gonna show'
wiki_url = "https://en.wikipedia.org/wiki/Special:Random"
article_page = requests.get(wiki_url)
client = discord.Client()
soup = BeautifulSoup(article_page.text, "html.parser")
article_title = soup.find(id='firstHeading')
#---------------------------------------------------------------------------------
#Func's
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = (message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'bot':
if user_message.lower() == 'hello wikibot':
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower == 'bye wikibot':
await message.channel.send(f'See you later {username}!')
while user_message.lower() == '!random wiki':
response = f'The title of the Random article is:, {article_title.string}'
await message.channel.send(response)
break
#---------------------------------------------------------------------------------
client.run(TOKEN)
You shouldn't make commands with on_message hold on a sec I will find a guide on commands
Also doesn't wikipedia have the API? Like it's easier to use than scraper imo
Then what should I use instead
As the command
I did link a guide
Maybe it was added in a 2.0
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
utils/utils.py lines 41 to 42
def datetime_to_timestamp(dt: datetime, modifier: str = "F") -> str:
return f"<t:{int(dt.timestamp())}:{modifier}>"```
Not very complicated as you can see
i am installing the discord slash module
but when i try to
import discord_slash
it says that there is no such module
did the module name change or something??


