#discord-bots
1 messages ยท Page 505 of 1
what does message_object mean
@client.event
async def on_message(msg):
for word in Filter:
if word in msg.content:
await msg.delete()
await client.process_commands(msg)
the message object
is this alrigtht?
u should use for loop
oh wait I am mad
The message. Don't save only the content but the whole message which u get via on_message so that u can also get the user info
huh
editted
bruh..
does it work now
lemme try
import discord
import keep_alive
from discord.ext import commands
from discord import utils
import datetime
prefix = "b."
client =commands.Bot(command_prefix=prefix, help_command=None, pass_context=True, owner_id=503035525456855051)
@client.event
async def on_ready():
print(f"Connected to {client.user}")
await client.change_presence(activity = discord.Activity(discord.ActivityTye.listening, name =f"to {prefix} in {str(len(client.guilds))} servers")
@client.command()
async def help(ctx):
embed=discord.Embed(title="Embed Bot", color=discord.Colour.random())
embed.add_field(name="\uD83E\uDDCA `"+prefix+"help`", value="Shows all commands' info", inline=False)
img = ctx.message.author.avatar_url
embed.set_thumbnail(url=img)
embed.add_field(name="\uD83E\uDDCA `"+prefix+"embed <message>`", value="Sends embeded message\n *(Requires 'Manage Messages' Permissions)*", inline=False)
embed.add_field(name="\uD83E\uDDCA `"+prefix+"about`", value="Shows info about the bot", inline=False)
embed.timestamp =datetime.datetime.utcnow()
embed.set_footer(text="Requested by {}".format(ctx.author))
await ctx.reply(embed=embed)```
Still error :<
!e ```py
if 'word' in 'some sentence with a word':
print('yes')
why not just
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
yes
F:\Python\monke bot\main.py:46: RuntimeWarning: coroutine 'Message.delete' was never awaited
msg.delete()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in command bant:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 22, in bant
await member.ban(reason=reason)
AttributeError: 'Context' object has no attribute 'ban'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
Ah, u r missing a closing bracket in change_presence()
So I want to Ban the user if the word is in the message
thats a tad extreme but ok
๐ฎ
Not even ban and kick
Haha happens
word_list = ['yes', 'no']
if any(word in message.content for word in word_list):
await message.author.ban()
this looks easy
Because of this bracket, I wasted 6 hours of mine and some people of this server
but it won't work unless I fix my errors
Aw, haha it surely can be a pain. I suggest u use an IDE something like VSCode
๐ฅ PC
I run VSCode on a 1.7 GHz processor and 4 GB RAM
Which Is Better? แทIT โทโโฃ
?
edit*
@tropic briaredited for multiple words
You have to get the message of the user you want to ban (the easiest way is with the message reference method)
@slate swan you can always DM me in case u need help setting up an IDE (:
Bot is now Online
Ignoring exception in on_message
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 45, in on_message
await msg.delete()
File "F:\monke bot\lib\site-packages\discord\message.py", line 1023, in delete
await self._state.http.delete_message(self.channel.id, self.id)
File "F:\monke bot\lib\site-packages\discord\http.py", line 250, in request
raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
Ignoring exception in on_message
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 45, in on_message
await msg.delete()
File "F:\monke bot\lib\site-packages\discord\message.py", line 1023, in delete
await self._state.http.delete_message(self.channel.id, self.id)
File "F:\monke bot\lib\site-packages\discord\http.py", line 250, in request
raise NotFound(r, data)
``` bot deletes my message when I try to ban but doesn' ban
What should I do.....never got this error...I understand the error but now what to do ._.
๐
Thanks a lot friend
await client.change_presence(activity = discord.Activity(discord.ActivityType.listening, name =f"to {prefix} in {str(len(client.guilds))} servers"))
TypeError: __init__() takes 1 positional argument but 2 were given```
I never said I gave the code. logic
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='.')
Filter = 'giant'
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity=discord.Game('Hello there!!'))
print('Bot is ready')
print('Bot is now Online')
@client.command()
async def kickt(member: discord.Member, *, reason=None):
await member.kick(reason=reason)
@client.command()
async def ban(member: discord.Member, *, reason=None):
await member.ban(reason=reason)
@client.command()
async def setdelay(ctx, seconds: int):
await ctx.channel.edit(slowmode_delay=seconds)
await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")
@client.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount)
@client.command()
async def delete(ctx, message):
await ctx.channel.delete(message)
@client.event
async def on_message(msg):
for word in Filter:
if word in msg.content:
await msg.delete()
await client.process_commands(msg)
show your init
!d discord.ext.commands.Bot.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the clientโs presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
I didnt made init
async def on_ready():
print(f"Connected to {client.user}")
await client.change_presence(activity = discord.Activity(discord.ActivityType.listening, name =f"to {prefix} in {str(len(client.guilds))} servers"))```
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
โข [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
โข [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
Those are kwargs
oooooooooo
type=discord.ActivityType.listening
So listeneing?
but why are you also converting a string to a string lol
Mhmmmmm ๐
len gives string?
no need to str()
f strings auto format to str
Yea that ^^^

I removed it
moves from python to compiled code sweat
@client.on_message
async def delete(ctx, message):
word_list = ['yes', 'no']
if any(word in message.content for word in word_list):
await message.author.ban()
``` Is this right?
indentioooooon
ohh
Imagine spoonfeeding
and brackets on decorator
Bruh.....?
Best is just to throw the bot away๐
What do u even wanna do
.....?
@client.on_message
async def delete(ctx, message):
word_list = ['yes', 'no']
if any(word in message.content for word in word_list):
await message.author.ban()
Well what to do about the activity btw
The deco is all wrong
Didn't I tell u?
@slate swan
wth How do I make it work
It's fine
Also i hate to make life difficult but don't change presence inside on_ready
Indeed
why?
Because it causes some weird behavior of the bot.
Actually I want my bot to refresh its guild number in activity as soon as possible but I dont want it to get rate limited
Then i recommend using an async function that will wait until ready.
async def wait_until_ready ??
Just refresh once 10 minutes in a task
since you share your ip adress meaning other people can rate limit you.
?
thats why it sucks
i like ur funny words, magic man
other people?
....?
So you got an adress assigned like a router, but repl.it has the same router for multiple users instead of their own network.
oooooo
So any other free platform other than heroku?
if only they get another
Nothing in life is free

i'll change that
I'll be there
Also how can I unblock my github 
except hate
then say asus without the a
I deleted some code but the ban command is still not working
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 22, in ban
await member.ban(reason=reason)
AttributeError: 'Context' object has no attribute 'ban'
@client.command()
async def ban(member: discord.Member, *, reason=None):
await member.ban(reason=reason)
you forgor ctx
oh
try this ```py
@client.command()
async def ban(ctx, member: discord.Member, *reason=None):
await member.ban(reason=reason)
so member becomes ctx
Not the correct channel. #python-discussion
@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
await ctx.member.ban(reason=reason)```
Where should I put my change_presense
except on_ready
!d discord.ext.commands.Bot.statis
!d discord.ext.commands.Bot.status
property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"): The status being used upon logging on to Discord.
!d discord.ext.commands.Bot.activity
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
The activity being used upon logging in.
Use these. Kwargs in the bot constructor
reference
or use the task like i said if you want to update it.
he gave 2
Bot is now Online
Ignoring exception in command ban:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 22, in ban
await member.ban(reason=reason)
File "F:\monke bot\lib\site-packages\discord\member.py", line 554, in ban
await self.guild.ban(self, **kwargs)
File "F:\monke bot\lib\site-packages\discord\guild.py", line 2026, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
File "F:\monke bot\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
Bot dont have perms
๐
Best code would be
@client.event
async def on_message(message):
await message.author.ban()

(Seriously don't try that code else RIP)
I won't be responsible if u try that code hehe
Ignoring exception in command ban:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "F:\Python\monke bot\main.py", line 22, in ban
await member.ban(reason=reason)
File "F:\monke bot\lib\site-packages\discord\member.py", line 554, in ban
await self.guild.ban(self, **kwargs)
File "F:\monke bot\lib\site-packages\discord\guild.py", line 2026, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
File "F:\monke bot\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\monke bot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "F:\monke bot\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
exception discord.Forbidden(response, message)```
Exception thatโs raised for when status code 403 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/master/api.html#discord.HTTPException "discord.HTTPException")
My progress
@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
Why is this not working
Now it even has admin permission
Your bot role should be above the user role that is banned
Question
The guild.unban command works with the Username#Discriminator right?
If i pass only the username in the command and then convert that username string into a User object and pass username and discriminator in guild.ban it should work right?
Uhh, nope
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create โminiatureโ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the objectโs hash.
It requires a Discord Object
Understand
So to make it work
I have to retrieve the id of the user
Then convert it again into a discord object
!pypi discord-anti-spam Now I will be using this
An easy to use package for anti-spam features in discord.py.
Yes
Btw i m using nextcord fork so i'll check documentation before coding lel
!customcooldown @tropic briar
Cooldowns in discord.py
Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.
from discord.ext import commands
message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)
@bot.event
async def on_message(message):
bucket = message_cooldown.get_bucket(message)
retry_after = bucket.update_rate_limit()
if retry_after:
await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
else:
await message.channel.send("Not ratelimited!")
from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.
Lol
The problem is if the bot can convert a string to a user object even if both doesn t share servers
But there is a solution to everything, it will be more annoying, but it will work anyway ๐
Cuz he is responding to it own message
this won't work
do you have an on_message event?
if msg.author.id == client.id:
return
@client.event()
async def on_message(msg):
if msg.author == client.user:
return
#your code
@client.event
async def on_message(message):
if message.author == client.user:
return
bucket = message_cooldown.get_bucket(message)
retry_after = bucket.update_rate_limit()
if retry_after:
await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
else:
await message.channel.send("Not ratelimited!")
bot command ideasss
but why a on_message event
omg pesron whose msg got pined aa
because spam will check when someone sends a message
I don't see this link on replit.com
huh
oh you are doing message spam, thought command cooldown
Where can I get that link
yea
Well, the better way is to set the slowmode on the channel but this works too lel
But i am unable to host it using replit
I cannot get that link
that I see in the video
?
Hi, In this video I will show you how to setup uptimerobot in order to keep your Python Discord Bot Online. This is part 2 and part 1 is required in order for part 2 to work.
๐UpTimeRobot: https://uptimerobot.com
๐ฌPART 1: https://youtu.be/g7n4OMy5tIY
๐Patreon: https://www.patreon.com/m692aus
๐ฅPlease Consider Subscribing:๐ฅ
https://www.youtube...
I am watching this video to host my bot
and I need that link as shown in the video
this is my screen
You re trying to hosting it by creating a flask and then continously sending HTPPS requests from another service
create flask app
huh?
the lowest you can go, replit is the WORST thing out there for hosting
lemme try
Lol that database made me cry
create a html file???
oh and with replit you want to keep resetting your token every 2 seconds
os.environ
because all your replits are public unless you have a paid account, but if you have a paid account you should just get a VPS
They added enviroment variables
I want to do this in free
sadly hosting costs money
where is flask apps
so there is no real free option
There are free also
Flask is a python package
create py file in your repo
already created one
Technically in the video he should show you how
Some year ago i tried to hosting a telegram bot for free
It made me even sick of php ๐ ๐
@tropic briar read this
self host
there is 1
tho most say it's free
Then the use of making a bot is non-sense?
i mean yeah
which
self hosting is considered free by most, tho you have to have hardware to run it already and need to pay for electricity and such
It has use if you re learning, but u can run the bot in your machine too
Well, just buy a Raspberry if so ๐
I will not be doing that all day
Can I use Heroku ?
read the same post
self hosting
so uh, you have a old laptop or phone, you install py in it and run ur bot
Then never turn that device off.
both are equally bad
it is not meant for bots, anything else good.
there is no good in replit or heroku for a bot
you'll run into tons of issues, annoyances, bad hosting, and you'll get tons of flak from all of the community
ull die or smthing idk
I am ready for those
Now should I?
i wont help you
ok ok
i'd say get a cheap VPS, those things only cost like a few dollars a month
anyways bye
a discord bot does not need much, like if a raspberry pi can run it almost anything can run it, except replit servers, because they are just bad in every thinkable way
How about free will
I m searching for a dedicated, i need both bot host and website host
i run a website with a few terrabytes of traffic a month, 2 discord bots, a reddit bot and sometimes some random project for only 6 euros a month
They will hunt you if you pee in public
on a VPS not dedicated even
replit is good to learn stuff and to not install an ide
Hello Guys
Whats the deal with an ide
Seems good, can you share me the VPS in dm? I m barely a novice with hosting
where can I get a good curse for Discord bots with python
almost anything works tbh. I use netcup, which has one downside: they only have a datacenter in germany
course*
so all servers are located there
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
almost all youtube tutorials are just nah
Thanks
Good luck for all of you
i mean they have new forks to code on
Well it is not like you can t found something, but to be honest most of them will teach you only the basic, it has use if you re starting with discord bot
Learn to use the documentation is the better way
Well, i live in Italy so it is not a big problem for me
i use their 6 euros plan
to get started use a course
I ll check it, thanks
THX
cries in rupees
can someone explane
async and await
are you new to python?
Lol
hmmm
Yes
so first things first
I know the basics
wrong link ?
thats uh for learning py, imma get async/await
In today's video, I'll be talking to you about asynchronous programming in python. This Python Async tutorial will cover the 'async' and 'await' keyword, coroutines, futures and tasks, and some basic features from the asyncio module in Python. This video is for intermediate programmers, and it's recommended you have Python 3.7 or above.
๐ป Algo...
Does it the same in Discord ?
In this video we learn about asynchronous programming in Python. We will talk about the keywords async and await.
โพโพโพโพโพโพโพโพโพโพโพโพโพโพโพโพโพ
๐ Programming Books & Merch ๐
๐ป The Algorithm Bible Book: https://www.neuralnine.com/books/
๐ The Python Bible Book: https://www.neuralnine.com/books/
๐ Programming Merch: https://www.neuralnine.com/shop
๐ป Exclusiv...
If you learn async await, you can use it for discord too
Thank you so muck for helping me
async await basically allows you to run stuff in the background
https://www.youtube.com/results?search_query=async+await+python
More results can be found here
Without running the code ?
after running the code
s
so.. lets say you are getting input ig, and you make a func that does stuff to it
so while that function is doing stuff we can also do stuff
so we can make it go run in the background
it's like multi tasking right ?
yep
but use the course to implement this in python :)
you'd also need an async scheduler though
If you don t use async/await your bot will sleep until the member you tempbanned is unbanned
it is in the vid i think
(omg i feel so good helping)
oh
I get it
Now I know the reason why we use async a lot in Discord.py
Btw, it will return an error if you do lol
Yes you're
aight imma go
Good luck body
thx
np
and uh buddy* (but if you meant a body...)
thanks for your time
np np
Cya
Is it possible to reference embed.Colour outside of the embed class?
!d discord.Colour
class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").
There is an alias for this called Color...
I remembered something weird that happened to me some days ago
I had those lines here:
print(f"{ctx.author.name} sent {ctx.message.content}\nNo command found for {[cnt[0] for cnt in ctx.message.content.split(' ')" )
Instead of gave me the command invoked it gave me some random letter in the string, i had to declare a list before and assign it to ctx.message.content.split
That doesn't help me
Well you asked for a reference, more info you did not provide.
he did tho
Embed.colour reference to discord.Colour
why "on_message" event making my bot crashed? It didn't send any error too
I still need it to change the embed, but I want the color to change base on an arg
@bot.event
async def on_message(message):
if message.content.startswith('@itsHarbinger#5005'):
e = await message.channel.send("itsHarbinger Is AFK: :CD_Inasleep:")
await asyncio.sleep(15)
await e.delete()
the code
i put it on my bot and it crashed my bot for no reason
it make my bot not respoding to another command
rather than on_message event
@bot.listen()
async def on_message(message):
if message.author.bot:
return
if message.content.startswith('@itsHarbinger#5005'):
return await message.channel.send("itsHarbinger Is AFK: :CD_Inasleep:", delete_after=15)
await bot.process_commands(message)
alright lemme try thx
@cloud dawn Still the same
It make my whole bot not responding
only the on_messgae itself
either use @bot.listen() as decorater, or add await bot.process_commands(message) to the bottom of @bot.event @vale narwhal
wha
I just shorten his current code
oh wait wrong ping my bad
I edited my msg @vale narwhal
Hey, buddies
I wanna self deploy @unkempt canyon bot.
But I don't have a pc. Me using termux to run simple codes but when It comes to the requirements of python bot. Termux failed to provide resources.
Can somebody help me with it
To deploy Python bot to heroku.
As heroku cli works pretty well.
I changed it to bot.listen() and it worked tysm!
credits go to diabolical

Hello,
Im trying to add a few emojis on an embed that I send to the channel so I can later react to them. But I cant really find how to go about it, what i wish there was is a command much like embed.add_field but for emojis. Any insights? :)
you mean react with emojis to the embed sent?
Yes, essentially make it so that the bot pre-reacts on the embed, so users can react on it once its displayed
is there any way to use the random library, but not repeat the same?
lets say i have
[1, 2, 3]
i use random.random and it gives 1, if i do it again it has to either say 2 or 3, cant say 1 again
No one have an answer to this? Lol
delete it from the list
embed_messae = await ctx.send(embed=your_embed) # store the message
await embed_message.add_reaction("emoji here (for example: ๐)") # add a reaction to the emed you just sent
uhh, can u tell me how to do that please?
Assume you have a list:
import random
list = [1, 2, 3, 4, 5]
choice = random.choice(list)
list.remove(choice)
x = [1,2,3]
random_number = random.choice(x)
x.remove(random_number)
oh that simple, thanks alot!
np
!e ```py
import random
numbers = [1, 2, 3]
for x in range(6):
try:
choice = random.choice(numbers)
except(IndexError):
break
print(choice)
numbers.remove(choice)
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
001 | 2
002 | 3
003 | 1
Do you copy the actual emoji or just the name for it
I ask again with not much hope ๐
actual emoji
message.add_reaction("๐")
Someone has a dict of discord reaction? Lol
You can also just use random.shuffle()
what?
yeah also its a coro so needs await
Something like:
[reaction_name: reaction_id, reaction_name1: reaction_id1, ...]
Because i found really annoying using the id to send emojis xD
Thank you! If i want to then listen to reactors, i read something about collectors so im going to look into that first. Could i achieve this by adding '.then' on the ctx.send(embed=embed).then like that and then processing and even adding everything in there?
can i make the embed image a gif?
that doesn't work in python unfortunately
!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.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
ty
simply do the next thing in the next line, instead of using .then()
Ah okay
Hello
Yeah, my async abilities are from Js so i assumed something like next was needed. Thanks for clarifying
Hello
np
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3.10/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3.10/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3.10/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
use ! as it is @unkempt canyon's prefix
!d help embed
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3.10/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3.10/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3.10/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
And you can test out in #bot-commands
Wait
How to make a embed help!
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, 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.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
What I have to do?
do to do that?
give me full command
@ember sorrel if my intention is to listen to the reactions, and im using client.command() to wait for the initial command to prompt the embed, do i need to setup a bot.event to listen for reactions?
Like if I say !help
im not going to give you the command, but you can use this for a reference to making an embed
Okay

you can do it either way, but it'll be better to wait for a reaction from the user after the command is invoked, after the bot has reacted to the embed, you can use wait_for()
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
This will definitely solve it, thank you!
np :)
Import "DiscordUtils" could not be resolved ๐ค can anyone help?
install the library...
I did
still saying the same thing
how do you install it?
pip install DiscordUtils
have you installed it in the same version of python you are using rn?
wdym
just to confirm, if i delete something from a list, and i restart the bot, the list is reset ya?
Yes
hello guys, quick question, how do i check when a member entered in the server?
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.
thx
np
hm
use a for loop and use wait_for() every time it iterates
isn't that possible?
I don't know much about slash commands so I'm just confiming,
ah well sadly I don't know then, I haven't really touched d.py ever since slash commands were added
My BOTs not detecting server Emoji's??
Meaning?
Is the emoji in the server?
Did u use the ID?
yes
How do I use it and how do i get it
add a backslash before an emoji then send it*
\๐ฅ
Can u explain a bit??
Doesnt work
Like this
\๐ฃ๏ธ
Use a custom emoji..
those are unicode emoji's they dont change lol
yes
client.get_emoji(439516188771483658)
or
bot.get_emoji(439516188771483658)
oops wrong message ping
hm
this one
Nice
Hey does anyone know why this doesn't work? Before when I only had users[str(user.id)]["Wallet"] += bet * 1000 it worked.
The problem is that it doesn't add the numbers to the json file, for example the it doesnt add bet to GEarned in the json file. Same to all those 5
@Bot.command()
async def Bot_Info(ctx:commands.Context):
await ctx.send({f"**{random.choice(Bot_Info)} im trying to make a random choice bot info command, but im not sure of the code ๐ค is it right or?
@Bot.command()
async def Bot_Info(ctx):
await ctx.send(f"**{random.choice(Bot_Info)}**")
``` you can just do this
Also I see a syntax error there
trying that now. Thanks it works ๐
@raven peak
async def Quote(ctx):
Quote = get_quote()
await ctx.send(Quote) this wont send a quote, ๐ค
def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " -" + json_data [0]['a']
return(quote)
both work
ok then his quote is empty
no reply
can you print Quote
oh, it worked. ๐ Is it poss, to bold print the quote?
How to let my bot react on his own message and when i react to 1๏ธโฃ it says like "text"?
yes, just use it like you normally do it
text
markdown works for bots
If someone invites a user how do we know that they invited them? like for example
@kayle#0000 joined by @Modmail#0000
any clues
it wont print the quote, in ""bold""
@raven peak
async def Hey(ctx:commands.Context):
await ctx.send(f"{random.choice(Replying_Words)}
{ctx.message.author.mention} ๐") it wont mention the user, whats wrong here?
ctx.author.mention
Store every invite the server has in a db, when someone joins compare each invite count, when one has more than it had previously get the owner of the invite and that's pretty much it
There's no other way to do it
hm
why the extra message?
\o/
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.
How to slove
Well the method would be:
1 - When an invite is created, store who created it and the invite information.
2 - When a user joins, check to see if they were invited. If so, check what link they used.
3 - Credit the person \o/
@client.event
async def on_guild_join():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f'{prefix}help in {len(client.guilds)} servers'))
error: on_guild_join() takes 0 positional arguments but 1 was given
Iโd like it to say Hey random_words/reply then mention the user.
ffmpeg was not found. Could be because ffmpeg is not a thing. Link code
I meant the extra message
you already used context lol
what import is that coming from @half briar ?
@drifting arrow what
What message?
{ctx.message.author.mention} ๐") it wont mention the user, whats wrong here?
see it now?
try putting discord infront of FFmpegPCMAudio
Help me please
Oo
No sorry ๐
from discord import FFmpegPCMAudio``` @drifting arrow
dude tf???
sc = discord.FFmpegPCMAudio("audio.mp3")
voi = vc.play(sc)
voi.start
tf?
events dont need parentheses
Tf = Total Fragination Nation
bro..
I removed it but same error
No clue, lol
That's basically exactly what I just said
I know. But he'd probs miss some parts.
You already had ctx and you did ctx.message.author.mention. I'm saying why did u add the extra message in that when you only needed ctx.author.mention?
Understandable ig
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg was not found.@drifting arrow
Now I understand ๐๐ผ
Need Help
is ffmpeg on PATH or in your bots cwd
idk tbh. I dont use the voice stuff since nobody here is willing to slide near the TOS stuff
Pretty sure that takes a guild param
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
@jade jolt cwd?
current working directory
hey, can anyone help me with finding apis for dadjokes? please thanks
literally first search result on google
!eval
@client.command(aliases=["unbanall"])
async def MassUnban(ctx):
try:
guild = ctx.message.guild
def UnbanAll(member_id):
r = requests.delete(f"https://discord.com/api/v9/guilds/{guild}/bans/{member_id}",
headers=headers)
if r.status_code == 200 or r.status_code == 201 or r.status_code == 204:
print(f'> Unbanned {member_id}')
@latent ermine :x: Your eval job has completed with return code 1.
001 | File "<string>", line 10
002 | print(f'> Unbanned {member_id}')
003 | ^
004 | SyntaxError: unexpected EOF while parsing
yea can someone help
yea i went to the tenth page and got random crap lmao that's why i didnt find anything
on_guild_join(guild)
whats this code..
for mass unbanning
BTW does anyone know how to send stickers with bot?
ah yes, massunban when passing a single member_id
lmao
why arent you using guild.unban
why are you trying to call the raw api
and why with requests?
whats the point?
dosent it make it faster
ok
The API has a guild.bans which return the lists of all banned users, use that
don't.
how come?
im wanting to make a command where an admin can say <giveroll [@user] [role ID] and it gives the specified user the role, how would i do that?
!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/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
so how do i target a user?
Pass a member: discord.Member into command arguments, or get the user with ID or utils or something
its an arg
ok
Like async def addrole(ctx, member: discord.Member, role: discord.Role)
!d discord.ext.commands.RoleConverter for role ids I think
class discord.ext.commands.RoleConverter(*args, **kwargs)```
Converts to a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
All lookups are via the local guild. If in a DM context, the converter raises [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") exception.
The lookup strategy is as follows (in order)...
It makes a huge API call I think
what comes after this?
@slate swan
use the name kwarg
?
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
im new to python and have never used kwarg before, can u explain that?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
not just 'addrole', but name='addrole'
!arg-kwarg
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
โข Decorators (see !tags decorators)
โข Inheritance (overriding methods)
โข Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
โข Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
quick question: py embed.set_footer(text="Requested by {}".format(ctx.author))
How do I bold the requester's name?
no, @raven peak doesn't take no positional argument
I genuinely don't care that I pinged somebody....
Help
Requested by *{}*?
or within the brackets?
no
nah it just print * in the footer
what does google say?
not found
how i can add a hyperlink in embed.add_fields
you cant there
oh..
i still dont know what to put after this someone pls help
then I don't think you can
await member.add_roles(role)
you mean that?
and use
@bot.command(name='addrole')
you can also leave it empty
indeed
but since we don't know how you want your command to work....
i think name is not a keyword only arg
yes its not
there is no *, before it
why ctx=None
was that dumb?
i dont know, you tell me
ok
but it shouldn't throw an error because of that, right?
because of what
because of =None
@hasty iron :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | def foo(a=1, b): pass
003 | ^
004 | SyntaxError: non-default argument follows default argument
yeah, i removed it and theres no error now
makes sense
so
it wont throw an error, if they're keyword arguments though
!e ```py
def foo(*, a=1, b): pass
@hasty iron :warning: Your eval job has completed with return code 0.
[No output]
thx it works now
and now that i understand how that works i can now add the removerole command
so i was working on a bot on my other pc, and it worked fine(except for a couple errors here and there), but when i tried to continue working on the same bot on my current pc, it gives me this error. it wasnt on my other pc:
ImportError: cannot import name 'PartialMessageable' from 'discord.channel'
do you have some kind of third party lib
idts. let me check
how do i make my command require certain perms to use again? i forgor
thx
@hasty iron yeah, i think i had a third party lib on this PC :kek
that could be the issue
yeah, i made a typo. edited the message now
thx
can someone tell me to escape from an error in aiosqlite?
try-except it?
now i get this:
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
reinstall discord.py
alright
im wanting to use embeds for my help menu, how do i do that?
you need an instance of discord.Guild not the class itself
this is why yu dont copy paste code you find on the internet lol
and image takes in bytes not Emoji or PartialEmoji
consider moving your commands to cogs dont put them in the main file
how specific
well i dont think stackoverflow answers would do such as a mistake to not use a Guild object
well you dont use self in a non-cog
is your code in the main file or in a cog?
!d discord.Guild.create_custom_emoji
await create_custom_emoji(*, name, image, roles=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.
There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.
You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
wait I thought you already removed discord.Guild from your code
that could be the only reason, because this function can't even raise a TypeError otherwise lmao
I can help, dm me pls
which database is best in discord.py?
hello
i want to know that do the message of the bot in dm is sent successfully or not
Postgres
how do i ensure that once the word "Pious" has been replied in the bots dm's, it does not continue to respond even if "Pious" is stated a second time
postgres is a website? :/
?
i use repl.it forr a yrs but i feeel great
or a library
you will get HTTPException if it fails
?? wdym?
U can add an if statement and a variable and check for its value
as a data base?
but ppls can see ur code
....?
in repl
Why not, itโs prob a quieter chat, lol
lmao
example? havent used python in many months
is postgres popular ?
uh... i want to know that if theres httpexception so we'll stop the program
using if-else
use isinstance()
i just want to store my variable safe that's why i want database
can you send a example code
Anybody got a on_member join code, that works, & a server_info code, pls.
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandInvokeError):
if isinstance(error.original, discord.HTTPException):```
you need to attach a file
as your command is coded in that way
Hello again, im trying to update an embed after sending it to the channel. What im trying to achieve is to add the names of everyone reacting to the embed. I read something about ctx.edit that uses discord.richembed but i cant seem to get it to work. Any thoughts?
yes
ok
kk
Hello
invite = ctx.channel.create_invite()
Will this code return a permanent invite?
can i connect postgreSQL with heroku?
Help pls
No
Then how to generate a permanent one?
!d discord.TextChannel.create_invite
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
help. this is my code for reaction role command, so when i write ?react3 then the message and the reaction pops out. But when i react to it, it doesn't give me the role. How to fix?
@client.command()
async def react3(ctx):
guild = ctx.guild
role = discord.utils.get(guild.roles, name="artist")
message = await ctx.send("React to me!")
while True:
await message.add_reaction(':white_check_mark:')
reaction = await ctx.wait_for_reaction(emoji=':white_check_mark:', message=message)
await ctx.add_roles(reaction.author, role)
open(help.html)```
Error: Command raised an exception: NameError: name 'Help' is not defined
On entering help it is supposed to open help.html (its in the same folder as the py file)
How do I do it?
Thanks
Fixed
That cursed annotation was placed there in order to fix a linter error
We have changed a couple of things and annotations are now okay
instead of waiting maybe use a on_raw_reaction_add and on_raw_reaction_remove ecent
okie!
still doesn't work...
what did you do in the event?
i didn't use event...
replit is not a database
no its a db lol
Replit has a db connected to it, so you can store stuff
But its not complex at all, it only allows for a single table
but it's bad
It is, but if youre a beginner i think its adequate
it's just json
Even actual json is better
mm
can i use sqlite ?
yeah sure but use aiosqlite3
how to fix this ```py
reaction = await ctx.message.wait_for_reaction('โ
')
it says message has no attribute wait_for_reaction and idk what to do
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
oh alright lemme read that
@unkempt canyon
open the link in the title, there's some examples
Im trying to update a single field in an embed thats been sent to the channel is there a way to achieve it easily?
yeah
okay
When i try and use embed_message.edit it collapses the old one and only title shows
save the embed in a variable, then edit the embed and edit the message
I save it as a variable as i send it to ctx
edit the embed like this: ```py
embed = discord.Embed(title="hello")
embed.title = "hey"
Hmm
the embed now is discord.Embed(title="hey")
If i have lets say 3 fields.. How would you specify to edit the first one
embed.fields[0] maybe, wait i'll do some tests
yeah it's right
!d discord.Embed.fields
property fields: List[_EmbedFieldProxy]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of `EmbedProxy` denoting the field contents.
See [`add_field()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.add_field "discord.Embed.add_field") for possible values you can access.
If the attribute has no value then [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") is returned.
So embed_message.field[0] =.. Can i still give it two parameters or should i send in a string containing both
embed_message.fields[0]
you can do like embed_message.fields[0].name = "something"
embed_message.fields[0].value = ...
embed_message.fields[0].inline = ...
yes, it is
no
there is database built in replit
that can't be called a database thought
yes but replit it self is not a databade
yes.
Im trying but it gives me invalid syntax. Do i need to import something to use. Fields
it's just a key: value
ikr
how i can store data like user levels and xp ?
screenshot what you did
a real database
use postgres maybe
it can but a databse would be better and secure
hmm
sql is case insensitive 
json is not built for levels or xp
i just want to confirm cuz i don't want to delete the code if it will not work in heroku
should i use sqlite or postgres?
its upto you rlly
you can do it with json lol but not recommended
will heroku change a json variables ?
sqlite is not for high traffic purposes, postgres is fine tho
yes
hmm, if you use heroku then json isn't the best choice (will never be)
@bot.group(invoke_without_command=True)
async def help(ctx):
It's only triggering on help
How can I make it to trigger on Help, HELP etx.
what
i think i should learn postgres so it will be good for future use too
await embed_message.fields[0].value = "test"
I get that the message object has no attribute fields
!d discord.ext.commands.Bot.case_insensitive
Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.
case_insensitive = True
oops it's embed_message.embeds[0].fields[0] and without await
hey i have question do i can use this
role = ## your role id
await ctx.channel.set_permissions(role, send_messages= False)```
does this work if i do it ?
no
why ?
so what should i do role = discord.role( my role id ? )
do get_role(<role_id>) and save in a variable
Hmm, when i first declare the embed, i then save it as a variable like this
await embed_message = await ctx.send(embed = embed)
I dont get anymore errors when i set up the edit like you wrote, however nothing happens when I react on the embed in discord
and put the variable in set_permissions
bruh too many awaits
just ```py
embed_message = await ctx.send(embed = embed)
embed = embed_message.embeds[0]
embed.value = "something"
await embed_message.edit(embed = embed)
await ctx.channel.set_permissions(role, send_messages= False)
My bad. My head is wobbley, there is only 1 await hahah
embeds aren't even coro's
get_role is not defined
idk is not defined
Thanks for the help! Ill get it soon enough
im_leaving is missing one required positional argument. (self)
Its just some trial and error to be done
it's Bot.get_role
i edited my message, scroll up
to this
Hmm, something is not allowing it to update
Bot as you need an instance of commands.Bot and not pasting the code in your bot ;-;
Setting up...
Traceback (most recent call last):
File "launcher.py", line 10, in <module>
main()
File "launcher.py", line 6, in main
bot.run()
File "/[REDACTED]/discord/bot/bot.py", line 21, in run
self.setup()
File "/[REDACTED]/discord/bot/bot.py", line 15, in setup
self.load_extension(f"bot.cogs.{cog}")
File "/[REDACTED]/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 676, in load_extension
raise errors.ExtensionNotFound(name)
discord.ext.commands.errors.ExtensionNotFound: Extension 'bot.cogs.cogs' could not be loaded.
Bot with small b?
this is the error
someone can give me ticket system?
im following this series: https://www.youtube.com/watch?v=iyQREXqHTsQ
Welcome to the discord.py music series - the series where I teach you how to build a music bot for yours and others' servers!
Series requirements can be found here:
https://files.carberra.xyz/requirements/discord-music-2020
You'll also need an IDE; I use Visual Studio Code in this series:
https://code.visualstudio.com/
The GitHub repository f...
whats the problem?
show the error
here
try bot.get_role, not Bot.get_role, Bot is a class, bot is your bot instance
yup this one works i think let me try
maybe you forgot to import something or pip installed it
huh its all in?
i got discord.py in
the code is written at like 7:42
scrub to there
?
ommand raised an exception: AttributeError: 'Bot' object has no attribute 'get_role'
ah, try ctx.guild.get_role i forgot it was on guild
How to check whether the user have a specific number of invites?
I found the issue, dont know how to get around it. I cant just do fields[0].value ="test" because fields[0] is a tuple
Does anyone know how to replace a tuple in an embed?
guys how can i send embed in dropdowns ?
when user click on dropdown options send embed instead message
are you using discord.py master branch?
isnt embed= embed_object working?
no thats not working like this
if fields[0] returns a tuple, why are you trying to do fields[0].value = ...
@client.command()
async def test(ctx):
embed = discord.Embed(title='testin bot', description='testing bot for drop down discord!')
my_embed1 = discord.Embed(title=f'Optionsf 1')
my_embed2 = discord.Embed(title=f'Optionsf 2')
my_embed3 = discord.Embed(title=f'Optionsf 3')
msg = await ctx.send(
embed=embed,
components=[
SelectMenu(
custom_id="test",
placeholder="Click nkni shab miyam to khabet !",
max_values=1,
options=[
SelectOption("Option 1", "value 1", description='All testing for bot', emoji='๐ค'),
SelectOption("Option 2", "value 2", description='All testing for bot', emoji='๐ค'),
SelectOption("Option 3", "value 3", description='All testing for bot', emoji='๐ค')
]
)
]
)
# Wait for someone to click on it
inter = await msg.wait_for_dropdown()
# Send what you received
labels = [option.label for option in inter.select_menu.selected_options]
await inter.reply(f"{', '.join(labels)}")
this is my code
you clearly dont have embed= .... in your inter.reply...
oh i will try this
@hasty iron i didnt know, i got help earlier but i just found out its a tuple. I tried converting it to a list and replacing the value, then converting it back and setting the embedded tuple to the new one. Didnt work
whats your code?
Can i tag you in half an hour. Gotta get home whilst the rain is slowing down a bit
property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
you can also do {user for guild in Bot.guilds for user in guild.members}
it would return a set of Member though
yeah
thats old
!d discord.Client.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
if you're going to copy code atleast copy something not outdated
do you have intents
add intents=discord.Intents.all() to your bot's constructor and enable them in your dev page
i cant read shit
how come
looks fine for me
okay someone can explain me why this https://paste.pythondiscord.com/vehaciyate.py always raise me ExtensionNotFound error?
Turn this on. It helps, trust me.
Invalid syntax, learn Python.
whats that
Battery saver.
Bruh what shall I do
yo?
I dont have it?
What is commands.?
Ok
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
^
ExtensionNotFound means that the extension you are trying to load is not in the given directory.
huh
I know that, but read the code and tell me why :_:
That does not fix it. And don't use client and bot together.
Ok
he did?
Yo, anyone here knows how to scrape a traceback to get the module which isn't imported?
NameError
I can check if the module is in the list of modules
How to get the name
Wait
!d NameError
exception NameError```
Raised when a local or global name is not found. This applies only to unqualified names. The associated value is an error message that includes the name that could not be found.
The `name` attribute can be set using a keyword-only argument to the constructor. When set it represent the name of the variable that was attempted to be accessed.
Changed in version 3.10: Added the `name` attribute.
I hope it has an attribute to get the name which errored
Still gonna use 3.8.6.
I use 3.9, sadly
How can I check if a user have a specific role?
