#discord-bots
1 messages · Page 572 of 1
Yea, its breaking with slots
Probably due to descriptors
And other than those two things the rest look fine?
It works yea
How ironic my entire discord lib is broken because of slots :^)
You likely need to add descriptors to slots I'd guess
Haven't used slots at all, so at this point it would just be a pain in the ass to make it work with the current codebase
But last time I used property with slots it worked fine
¯_(ツ)_/¯
You just define slots with the attributes you want on said class and thats it tho, just gotta get said attributes correct
Seems easy enough, but as of right now it's just a chore that I do not have time for
I have a command in which you need to mention someone for it to work, how can i make it so if you dont mention it mentions the author of the message
OMG GUYS MY BOT BECOME VERIFYED!!
just default the mention argument to None (typehint it to discord.User or discord.Member), then check if the argument is None
MY BOT IS VERIFED!!!!!!!!!!
nice
a little confused
I BEEN WORKING THE FUCKING BOT for 2 YEARS!
AND IT FINANLY CAME TO WORK
in the idle..........
Visual Studio is what i use, you can use pyCharm
no just no
its all opinion based :(
he should start with the idle and then move to vs code but i dont recommend pycharm for beginners
vs code is good but atleast have a bit of knowledge
im beggining with vs code
@slate swan you expierneced?
i need a bit of help with a quick something
i mean go for ig
meh idk
I have a command in which you need to mention someone for it to work, how can i make it so if you dont mention it mentions the author of the message

never done it before so its all yours brother
user : discord.Member = None
is what i meant
aHhhh
just check:
if user:
# user is provided
else:
# nope
then just author.mention
alright
not exactly but something like that (sorry i dont spoonfeed)
ctx.author if you want the author object
unless if you wanna mention them
thanks
but i assume not
yuh
yeah that worked
wait actually no it didnt
now when i mention someone it goes to author
if you use ctx.author.mention it mentions the author
if you use user.mention it mentions the user provided
did you use ctx.author.mention
since youre the person who invoked the command i assume
@slate swan can u add me one more time i need to show u smthing private
funny command
..
user = user or ctx.author
# process command

why give me erros?
regenerate your token
oh k
now
i did but it still give me the same erros
i dont believe that your bot got verified when you just leaked your token
lmao
can u help me tho
maybe cuz you added 3 of `
at the end
homie just leaked his token lol
guys
frr
bruh
Why do you have ``` in your codfe lol
stop making fun of me for god sake
if your gonna copy code do it right
im so a idiot i ddint even see it
prob\
maybehewanna type in discord
isnt? @slate swan
""
use in""
add me as a Frined
he is suffocating
and its client.run("your token")
ok
exactly
fr
not maybe client.run can use bot.run ext whatever you use
no mean to be rude but its friends*
yeah ik but hes using client
WOWOWOWO
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 109, in on_message
top=asyncio.subreddit.top()
AttributeError: 'coroutine' object has no attribute 'top```
your bots token is like its password you dont show it to anybody
whats this error
show me the full code
ok
yes
@slate swan maybe he missed an argument
isnt?
i had a prob with prefix change command
never works
reddit = asyncpraw.Reddit(
client_id=os.getenv("CI"),
client_secret=os.getenv("CS"),
user_agent="lol23",
username="awaffle11",
password=os.getenv("P")
)```
watched 100000s of tutos
this is the first part
bro....
the error is not their
@client.event
async def on_ready():
elif message.content.startswith(">meme"):
asyncio.subreddit=reddit.subreddit("memes")
all_subs=[]
top=asyncio.subreddit.top()
for submission in top:
all_subs.append(submission)
random_sub =random.choice(all_subs)
name=random_sub.title
url=random_sub.url
em= discord.Embed(title=name)
em.set_image(url=url)
await message.channel.send(embed=em)```
its
top = subreddit.top(limit = 100)
@ornate lichen 
it says subreddit is undefined
define the subreddit
should look like this idk why your using asyncio
subreddit = await reddit.subreddit("the subrredit")
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 113, in on_message
for submission in top:
TypeError: 'ListingGenerator' object is not iterable```
what are you trying to do exatly
use random
In this video, we will learn how to get data from Reddit using python for a Discord bot. We will make the meme command in this video.
If you have any suggestions for future videos, leave it in the comments below.
Some Useful Links -
Reddit Applications- https://reddit.com/prefs/apps
My Discord Server- https://discord.gg/TXF3hBj
My Twitter...
This can help
i dont think so
hes code doesnt look like that
cos idk how to use client command
just use bot lmfao
i have a working command like his
that i followed in his video
@ornate lichen why are you using asyncio?
yeah i see that
then thats what it showed
not the best thing to do
yeaaa..
dont copy code you dont understand
just follow his steps and you will be ok
Btw its not the best thing to use async praw or discord.py as a beginner
oh ok
If your trying to learn python i recommend:
https://youtube.com/playlist?list=PLBZBJbE_rGRWeh5mIBhD-hhDwSEDxogDg
Traceback (most recent call last):
File "main.py", line 65, in <module>
@quaint axle.command()
AttributeError: 'Client' object has no attribute 'command'
this is what im getting now
i followed his steps
@slate swan
Its client.command()
yup thats what i did
@client.command()
async def meme(ctx):
subreddit = reddit.subreddit("memes")
all_subs=[]
top = subreddit.top(limit = 100)
for submission in top:
all_subs.append(submission)
random_sub =random.choice(all_subs)
name=random_sub.title
url=random_sub.url
em= discord.Embed(title=name)
em.set_image(url=url)
await ctx.send(embed=em)```
Wdym by timezone of the server
means if the server's region is south africa then the bot should show there time in embed
Ah i see
?
Never done it before🤷♂️
Use timezone aware datetimes
timestamp field is converted to user time by default if its aware
iirc
Well, discord renders it as a nice time since
Does it make the time zone = to the server owners time zone or does it just do it generally
The discord client will render the timezone in relation to that client's computers time
It will also do stuff like 10 minutes ago
I see
@slate swan
i followed all the code
but when i run the command
nth shows up
no error either
which version is discord.py rn?
Code?
hey
do you know how to make it so when i react to the message the bot sends, the bot will reply with like for example "{user} has agreed to this message"
lemme copy my code 1 sec
On a member reaction on a message the bot will reply with a message of who reacted with a certain emoji?
yea
@bot.command(aliases=['tg', 'Touchgrass'])
async def touchgrass(ctx):
emoji = ':touch_grass:'
def check(reaction, user):
return user == ctx.author and (str(reaction.emoji) == emoji)
message = await ctx.send("react to touch some grass")
await message.add_reaction(emoji)
try:
await bot.wait_for("reaction_add", timeout=10.0, check=check)
await ctx.send('you have touched grass today')
except:
await ctx.send('bro u didnt react smh')
this is my code so far
Any errors?
hi i need help please.
async def on_ready():
print('aerial is online')
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(bot.guilds)} servers and {len(bot.users)} '))```
how do i make it like see how many people are using my bot? it seems like lenbot.users isn't working
guys how to add change prefix command
Dont really know sorry
Wdym prefix command dr
oh ok lol thanks
yo guys is there a way to connect a gui to a discord bot?
Like, original CMD and the one where when people add your bot, you could change it in a certain server. Like haunting, .prefix * < example
i think it's bot.guilds
Ahhhh
@slate swan is this so?
Yes.Oops wrong person myb
Its alr
@slate swan coudl you please help me?
i want to make it say like watching [guilds and (guild total users)]
You want it to get a total of all the guilds and the total users in all guilds?
Yes.
Now it says this
the code ^
use one more (
You have two closing parenthesis
no {
like connecting tkinter to a bot
And one is at the wrong position
so i can control it
what
he did somethiong wrong guys
hey guys wait
async def on_ready():
print('aerial is online')
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(bot.guilds)} servers and {len(bot.guild.user} '))
``` could you please help me.
@bot.event
async def on_ready():
print('aerial is online')
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(bot.guilds)} servers and {len(bot.guild.user)}'))
is that it?
okay, but now it says this Ignoring exception in on_ready
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 25, in on_ready
name=f'{len(bot.guilds)} servers and {len(bot.guilds.user)}'))
AttributeError: 'list' object has no attribute 'user'
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 25, in on_ready
name=f'{len(bot.guilds)} servers and {len(bot.guilds.user)}'))
AttributeError: 'list' object has no attribute 'user'```my bad
ive been trying to fix it
Yes it doesnt it's a list
@bot.event
async def on_ready():
print('aerial is online')
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(bot.guilds)} servers and {len(bot.guild.user)} '
try this once
Okay
That's straight up wrong
yeah it's wrong
how do i fix it
See if you print bot.guilds you will understand that it's a list not an object
now it's on here 
idk how to fix it, i'm sorry i'm very new to coding
the code
async def on_ready():
print('aerial is online')
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(bot.guilds)} servers and {len(bot.guild.user)}'
@bot.command()
async def slap(ctx, user: discord.Member):
a =['https://tenor.com/view/anime-slap-mad-gif-16057834','https://tenor.com/view/powerful-head-slap-anime-death-tragic-gif-14358509','https://tenor.com/view/chikku-neesan-girl-hit-wall-stfu-anime-girl-smack-gif-17078255']
embed = discord.Embed(
color=discord.Color.dark_theme())
await ctx.send(random.choice(a))
await ctx.send (embed)```
Try len(bot.guilds) if you want to get the number of guilds
Ok
^
refresh the page you mean?
No
No you forgot the ) to close the func
Revert it to this
Ohh i fixed it
i did, now it shows this error
See first of all guilds is a list
https://discordpy.readthedocs.io/en/latest/api.html?highlight=guilds#discord.Client.guilds
It will not have a user argument
You need member intents
You forgot to write members in the status and you need members intents for anything related to members
Can you please not ping me when replying to stuff with arrows
Sorry wont do again
ty
Np
how can we make a prefix change
commandwith discord.py
help
somebody help
How to copy a picture sent in one channel
thats really basic
google it
no
that dont work
client is not accessed
can yoy snd me code example
<@&409416496733880320>
hhhhhhhhhhhhhhhhhreeeeeeeeeeeeeeelp
help
i am dying for help
@slate swan thank god
someone came up
uh no
To sleepy to do it myself
thanks
for help
Yw
don't ping random people
lol peter and strange
Isn't a good way
it uses a dict
it'll reset when the bot restarts
code
async with aiohttp.ClientSession() as cs:
r = await cs.get('https://api.tamako.tech/api/roleplay/cry')
cry_url = (await r.json())['url']```
error:
thanks!
print(nome)
print(data)
print(nome in data)```
ik
[('ik', 123)]
False```
why
yes
nome = message.content
wdym
!e
a = "ik"
data = [("ik", 123)]
print(a in data)
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
False
@floral jacinth
¯_(ツ)_/¯
how should do that control then
control?
use @client.command
An if statement..?
you mean the commands extension
thats the decorator for it
i did right after and never entered
that's why i asked
icon_url=member.avatar_url
AttributeError: 'Member' object has no attribute 'avatar_url'
```?
did you use member: discord.Member as an argument in your function
member is payload.member in the menu
wait
@menus.button('\N{THUMBS UP SIGN}')
async def on_thumbs_up(self, payload):
await self.message.edit(embed=self.CEmbed(member=payload.member, text=f"Thanks, {payload.member.display_name}!", text2=":D"))
def CEmbed(self, *, member, text, text2):
embed = discord.Embed(
title=f"**{text}**",
description=f"*{text2}*",
colour=discord.Colour.random()
)
embed.set_author(
name=member.display_name,
icon_url=member.avatar_url
)
return embed
if you're on dpy 2.0, it would be member.avatar.url
oh nice
so it seems like the docs aren't fully updated
they are
you're viewing 1.7's docs
oh this is the stable one
oof
it also shows 2.0 things
master branch is 2.0, so it obviously shows 2.0 things
stable one also
No
https://discordpy.readthedocs.io/en/latest/ shows the docs for v1.7.x
Voice channels can't play music
he isn't actually talking about the voice channel hes talking about his bot
why would you assume that
How can I make the Voice Channel play mp3 files in a loop?
Not rocket science ¯_(ツ)_/¯
latest and stable will be the pypi releases
feedbackmessage = await self.client.wait_for('message', check=lambda message: message.author == user)
can i wait for the message and if someone in the meantime adds a reaction to a message, it cancels the request for a message(feedbackmessage)
One help
How I can make a bot that will make channels and manage permission
I need the full code actually 😅
Well we don't just give away entire bots
don't spoonfeed
You know how u can do like channel = client.get_channel(id)
will it work the same for voice channels?
Yes
Ok ty
voice channel == text channel
@bot.command(aliases=['tg', 'Touchgrass'])
async def touchgrass(ctx):
emoji = ''
def check(reaction, user):
return user == ctx.author and (str(reaction.emoji) == emoji)
message = await ctx.send("react to touch some grass")
await message.add_reaction(emoji)
try:
reaction, user = await bot.wait_for("reaction_add", timeout=10.0, check=check)
await ctx.send(f'**{user}** was the first to touch grass')
except:
await ctx.send('no one touched grass in time')
how do i make it so it also tracks reactions from other users? it only checks the reaction for the author in the code
touchgrass 💀
you did return user == ctx.author and (str(reaction.emoji) == emoji)
i delete the whole line?
Just remove the user check since everyone is allowed, and just check for the reaction
Eventually just check if the user is not a bot
ok
remove the whole line?
ok
thats the function
all of it
No
Keep the reaction emote check
Just remove user == ctx.author and
But keep what's coming after
ok
@bot.command(aliases=['tg', 'Touchgrass'])
async def touchgrass(ctx):
emoji = ''
def check(reaction, user):
message = await ctx.send("react to touch some grass")
await message.add_reaction(emoji)
try:
reaction, user = await bot.wait_for("reaction_add", timeout=10.0, check=check)
await ctx.send(f'**{user}** was the first to touch grass')
except:
await ctx.send('no one touched grass in time')
like that?
a
a
^
So add that to the return of the def check
Something like not user.bot
def check(reaction, user):
return (str(reaction.emoji) == emoji) not user.bot
and not
ty
Sometimes we have messages that have text + embed
So both non embeded text and embeded text in one
Now my issue is that I want to edit the non embeded text but keep the same embed
I tried using:
embed = msg.embeds[0]
await msg.edit("Status: Hit!",embed=embed)
But the edit() method only takes 1 argument so this doesnt work... any way around?
it works now
content="Status..."
oh ty

@client.command()
async def pressf(ctx, *, because : str = None) :
msg = await ctx.send(f"Press f for {because}")
await msg.add_reaction(":pressf:")
await asyncio.sleep(15)
cache_message = discord.utils.get(client.message, id = msg.id)
for reactor in cache_message.reactions :
reactors = await client.get_reaction_users(reactor)
for member in reactors :
await ctx.reply(member.name)
it is saying object bot has no attribute message
client.cached_messages
what you mean?
replace your client.message with it
!d discord.Client.cached_messages
property cached_messages: Sequence[Message]```
Read-only list of messages the connected client has cached.
New in version 1.1.
@unkempt canyon
Anyone know how I can send messages like this? Or how those are called, so I can look it up
ephemeral messages
and it can only be send in the callback of an interaction (slash commands, user commands, buttons, dropdowns)
Oh and how can I create a button? Instead of on_raw_reaction_add ?
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
subclass this class and create a method named callback then you can do that stuff there
thanks
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/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/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
Who knows this embed color's num?
Id int
hmm
What if I have two identical reports and when I click the close button in one of them, the bot sends a message to another channel with a report, how can I fix this?
@bot.event
async def on_member_join(self, member):
await self.bot.send(member,"Welcome!")
Would this work?
Nop, you should read the documentation, in order to send a message you have to call the send on a messagable i.e. member.send(...), if you're also inside a class (cog subclass) use cog.listener
Thanks 😄
no offence but use a fork rather than a 3rd party lib
How would I specify which channel the message should be sent to?
get_channel(id, /)```
Returns a channel or thread with the given ID.
get_channel(here)
No like what I mean is
@commands.Cog.listener()
async def on_member_join(self, member):
await self.bot.send(member,"Welcome!")
where in here would I put the get_channel
thats easy
@commands.Cog.listener()
async def on_member_join(self, member):
channel = await bot.get_channel(welcome_channel_id)
await channel.send(member,"Welcome!") ```
@slate swan
add ur welcome channel id variable or replace the welcome_channel_id to there
i think
idk i havent used cogs
id recomend a variable up top or in a config file so u dont have to go back and find it
i have alot of variables
I run the bot, my friend joins and it doesnt send crap
u are using cogs right
what theme do you use in vscode
You need members intents
Whats that?
!d intents
🤷♂️
sublime monkai?? @rare saddle
I have not installed extensions
you have to add the lines below to your code and activate members intents in the dev portal
the lines:
from discord import Intents
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix ="",help_command = None,intents=intents)
hey man
see this
just a sec
I don't understand what you want from me, this theme was the default, ask questions please
im doing this in a cog so do i just add this to my cog?
ohh ok
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.idle)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Godzilla vs Kong(2021) "))
print('Loki In Charge as @{0.user}')
this
isnt working
ok with watching
a cog doesnt use that?
but idle noppe
ok nvm
when i view init
i found if status invisible
a cog are for commands and other things that just goes to the top of your code
@slate swan i get this error. send() takes from 1 to 2 positional arguments but 3 were given
so even when i try invisible, didnt work\
what have you gave
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(903695632877895693)
await channel.send(member,"Welcome!")
idk try
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(903695632877895693).send(member,"Welcome!") ```
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.idle)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Godzilla vs Kong(2021) "))
print('Loki In Charge as @{0.user}')
this isnt working ok with watching but idle no working when i view init i found if status invisible so even when i try invisible, didnt work so could anyone help me??
@slate swan
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.idle)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Godzilla vs Kong(2021) "))
print('Loki In Charge as @{0.user}')
this isnt working ok with watching but idle no working when i view init i found if status invisible so even when i try invisible, didnt work so could anyone help me??
same thing
same error
Try deleting bot.
@slate swan
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.idle)
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Godzilla vs Kong(2021) "))
print('Loki In Charge as @{0.user}')
this isnt working ok with watching but idle no working when i view init i found if status invisible so even when i try invisible, didnt work so could anyone help me??
Don't change presence on on_ready
Use the kwargs made for it in the bot constructor
Such as
bot = Bot(activity=discord.Activity(type=discord.ActivityType.xxxxx, name="xxxxx"), status=discord.Status.xxxxx)
Im in school chill out dont spam ping me either
ok
And yeah, spamming won't give you more attention
and
It's even the opposite, people will ignore you for being annoying
i didnt got you actually
ok
Doesn't matter
cause im waiting 10 mins
Trying to be nice
Spamming your question 10 times copy pasting it won't give you more attention
People wait for hours🤷♂️
ok
People will ignore you, starting with the ones you ping
like me
Anyways, here's your answer
ok you the best @slate swan
but idk why you pay for winrar
Because I can.
bruh\
.
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Please send the piece of code where it raises that error instead of sending your whole code. And also, I would like to comment on your nickname, as it's not very nice nor cool. 🙂
how can I say that when a user sends that command, an embed appears on a dedicated channel?
Does anyone have an idea of how I can make my own cooldown?
But whenever I restart the bot the cooldown should not reset
You should store it in a db (the last execution time)
But how do I check if its over
I know how to do the first thing thats all
Well, in on_command, check the last execution time and the current time and just subtract...?
Idk, that seems like the only way afaik
!d discord.TextChannel.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Maybe I can make a custom check
You could also muddle the cooldown internals to persist them
Save on shutdown kinda thing
Uh
Too much work?
Sounds about right tbf, I tried making a persistent cooldown package but 2.0 fucked the internals so i dropped it. Although its quite simple for 1.7.x
Idk lmfao, I have some commands that has hours of cooldown, works fine, but whenever I restart it annoys me that it resets
You can try save internals on shutdown and then on startup reset em
But atm no way I think
Might look back into it tho, can try remember to @ you if i do
Yea, that's fine, I'll try that way
how can I say that when a user sends that command, an embed appears on a dedicated channel?
Use get_channel and send it there
wait
Get_channel returns a discord.TextChannel obj so you can use that
poll_msg = await ctx.channel.send(embed = pollEmbed)```
i have used this but don't work (sorry for the bad english)
Ctx.channel is the channel they used the command in, remove ctx from it and then it will send to urchannel
await channel.send ?
Ye
Np
@valid perch is there an event which triggers when a cooldown for a command ends?
Fk
Ik in 1.7 it wouldn't be hard to save em, or too hard. But I assume you use 2.0?
Also which fork
guys does anyone know how to make discord buttons?
Nah im not using 2.0
I'm using 1.7 but with dislash, anyway I'm soon gonna migrate to disnake
easy
read the docs & examples 😎
Well if you can be bothered making something for 1.7.x
for c in bot.walk_commands():
x = c._buckets
print(c.name, x._cache, x._cooldown, x._verify_cache_integrity)
Will give you the info you need + I think there was another field
Tis as good a starting place as any
How to use edit message in webhooks
but there is nothing about buttons
in discord.py
Ah alright thanks
!d discord.Webhook.edit_message
await edit_message(message_id, *, content=..., embeds=..., embed=..., file=..., files=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits a message owned by this webhook.
This is a lower level interface to [`WebhookMessage.edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.WebhookMessage.edit "discord.WebhookMessage.edit") in case you only have an ID.
New in version 1.6.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited message is returned.
@slate swan thank you
How do i ctx.send a msg when Forbidden error is raised
you can't
that's the point of the error
or if you mean raising an error
use the on_command_error event
which I can't find
check if the error is a discord.Forbidden with isinstance()
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Well ye sending a ctx msg when Forbidden is there
except discord.Forbidden
I mean a general thing, except works in a command only no?
no
You right now🧠
what
Idek what to say
I think he wants a error handler
For forbidden errors
Ye
what code do i need to use for welcome messages
on_member_join()
thanks
how to ping the user
.mention
on_member_join(Welcome .mention to our server!)
Ok?
is that correct?
Not at all
https://github.com/Astro-dbot/Astro-Cord
this is a script which takes in a user's bot's info and generates a ready made script for the bot to run
A discord.py code generator program. Compatible with both linux and windows. - GitHub - Astro-dbot/Astro-Cord: A discord.py code generator program. Compatible with both linux and windows.
then?
pls review anyone
Ignoring exception in command профиль:
Traceback (most recent call last):
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "O:\Suzuki\cogs\info.py", line 145, in profile
await ctx.reply(embed = embed)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\context.py", line 340, in reply
return await self.message.reply(content, **kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\message.py", line 1358, in reply
return await self.channel.send(content, reference=self, **kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 1065, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.thumbnail.url: Scheme "8f04c6e23b14597c224414ae88406611" is not supported. Scheme must be one of ('http', 'https').
!resources try this
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
i dont have any capable developers to review my product
code
@commands.command(name= "профиль")
async def profile(self, ctx: commands.Context,member:discord.Member = None, guild: discord.Guild = None):
if member == None:
embed = discord.Embed (
title = 'Ваш профиль',
colour = ctx.message.author.color
)
t = ctx.message.author.status
if t == discord.Status.online:
d = "🟢 В сети"
t = ctx.message.author.status
if t == discord.Status.offline:
d = "◉ Не в сети"
t = ctx.message.author.status
if t == discord.Status.idle:
d = "🌙 Не активен"
t = ctx.message.author.status
if t == discord.Status.dnd:
d = "⛔ Не беспокоить"
embed.add_field(name= "Ник:", value = ctx.message.author.mention)
embed.add_field(name= "Статус:", value=f"`{d}`")
embed.add_field(name= "Основная роль:", value = ctx.message.author.top_role.mention)
embed.add_field(name= "Дата создания:", value = f"<t:{int(ctx.message.author.created_at.replace(tzinfo=DT.timezone.utc).timestamp())}:D>")
embed.add_field(name= "Дата присоединения:", value= f"<t:{int(ctx.message.author.joined_at.replace(tzinfo=DT.timezone.utc).timestamp())}:D>")
embed.add_field(name= "Количество ролей:", value=f"`{len(ctx.message.author.roles)- 1}`")
embed.set_thumbnail(url=ctx.message.author.avatar)
await ctx.reply(embed = embed)
thankss
else:
embed = discord.Embed (
title = f'Профиль **{member.display_name}**',
colour = member.color
)
t = member.status
if t == discord.Status.online:
d = "🟢 В сети"
t = member.status
if t == discord.Status.offline:
d = "◉ Не в сети"
t = member.status
if t == discord.Status.idle:
d = "🌙 Не активен"
t = member.status
if t == discord.Status.dnd:
d = "⛔ Не беспокоить"
embed.add_field(name= "Ник:", value = member.mention)
embed.add_field(name= "Статус:", value=f"`{d}`")
embed.add_field(name= "Основная роль:", value = member.top_role.mention)
embed.add_field(name= "Дата создания:", value = f"<t:{int(member.created_at.replace(tzinfo=DT.timezone.utc).timestamp())}:D>")
embed.add_field(name= "Дата присоединения:", value= f"<t:{int(member.joined_at.replace(tzinfo=DT.timezone.utc).timestamp())}:D>")
embed.add_field(name= "Количество ролей:", value=f"`{len(member.roles)- 1}`")
embed.set_thumbnail(url=member.avatar)
await ctx.reply(embed = embed)
pls check my message above
Yw
pls check my message above
help
pls review my product
client = commands.Bot() # Don't do like that
bot = commands.Bot() # Do like that
oh
Not the worst, but there are a few bad practices such as naming a commands.Bot object client and not using F strings
well can u make a pull request
Some indentation would also be nice
actually i just wanted to start off with this project for once
i will keep working on it more
and thinking of making it into a gui
if u have any suggestion or code fix you can create a pull request and in the repo
Wouldn't make a gui to be honest
?
well won't it be nicer?
hmm thanks
You didn't give a valid URL for the embed thumbnail
ok
how to check if a channel exists
Use get_channel/fetch_channel, and if it returns None, then it doesn't exist
Dont recommend fetch it makes a api call
Just use get_channel
No
Because get_channel can return None if the channel is not in cache
But that doesn't mean it doesn't exist
So it basically just doesnt find it in cache?
Yup
So like everything, use get_channel(id) or await fetch_channel(id)
The more you know
so that it doesn't always make the api call
only when needed
Yeah i know what you mean use get_channel if not just use fetch
Guys a question
The role ID is unique for each role right?
Yes
Every ID is unique for everything
Its basically like a credit card
Everybody has their own code or digits
Weird example ik
Lol
that's why it's called a snowflake
every ID is supposed to be completely unique
kind of like a snowflake, i guess
Yeah you can say that
under the "reference" section they outline how they generate IDs
Just based on the snowflake algorithm of twitter
Made the same for something I'm working on
async def on_member_join(self, member):
channel = self.bot.get_channel(903695632877895693)
await channel.send("Welcome!")
role = discord.utils.get(member.guild.roles, name="−∙ Member ∙−")
await member.add_roles(member, role)```
Im trying to give a role to a new member, but when the member joins theres an error 404 Not Found (error code: 10011): Unknown Role*
Get the role by id, much better
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
Thanks!
import discord
client = discord.Client()
@client.event
async def on_ready():
print('Bot is working as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('$You are dumb.') and message.Author == client.user:
await message.channel.send('Yes, I am, my master.')
if message.content.startswith('$You are dumb.'):
await message.channel.send('Shut up you lil kid.')
client.run('token here')
So why is nothing happening when I say 'You are dumb.' its supposed to say 'yes i am my master' cuz imm the owner of the bot (client user)
!d discord.ext.commands.Bot.user haha no - client.user is the bot itself in an instance of discord.User. Print client.user and you will see what I mean :)
property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
there is no attribute where it will only respond to you, the owner - it doesnt know you are the owner
👍
Your message should start with $You are dumb. and not You are dumb.
And compare with message.author.id == your_id
And client.user is not the owner of the bot, it's just a user representation of the bot
typically people put tokens in .env files, but I’ve always found that a hassle
mhm okey
Heroku's config vars
oke
how would I put the "must be 2000 characters or less" error in an except:?
exception discord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
To specify the server do you use guild or server?
that is the error, so you do except discord.errors.HTTPException: return
elaborate.
Like if i was to print a server that a member is in
would I use, member.Guild or member.Server
so do I do
except discord.errors.HTTPException?
!d discord.Member.guild || member.server does not exist
The guild that the member belongs to.
thanks
correct.
thanks
that is not possible.
maybe you mean discord.User?
discord.Member always has a guild attr, seeing as member correlates directly with guild
role = discord.Member.Guild.get_role(904757916526071828)
I said lowercase guild.
ohh yeah soz
also this will never work
you need an actual member object, not just discord.Member.
404 Not Found (error code: 10011): Unknown Role
You need an instance of Member not the class itself
async def on_member_join(self, member):
then use member.guild, not discord.Member.guild.
role = member.guild.get_role(904757916526071828)
correct
it says unknown role
then the role id is incorrect.
|| not a valid role ||
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(903695632877895693)
await channel.send("Welcome!")
role = member.guild.get_role(904757916526071828)
await member.add_roles(member, role)
!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.
My code for a log doesn't work I based it off someone's on stack overflow and made edits
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(903695632877895693)
await channel.send("Welcome!")
role = member.guild.get_role(904757916526071828)
await member.add_roles(member, role)
you are doing await member.add_roles(member, role) remove the member.
What's the error
You did member.add_roles, you only pass one arg; role. You are passing member twice
a: show code
b: show error
c: say expected output
👍
how do i get the changed perms as
Added:- wutevr i added
Removed:- Wutevr i removed
```and in an embed
A: https://paste.pythondiscord.com/jenabotunu.py
B: not working error in terminal
C: wanting to log a message
it is in there though
why the hell did you put self
and
pov: you blindly copy paste codes
!d discord.on_message_delete
discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
I based it off other code but edited to fit my bot
only takes message. Meaning you have added an extra arg, being message (you put self, because the code was in a cog, but yours isn't). You also put self.bot yet you use client. copy and paste reee
await ctx.send(len(ctx.guild.private_channels))
``` is a thing?
yes but no
yes but yes.
but no
!d discord.Guild.private_channels || no.
No documentation found for the requested symbol.
Private channels??
aighty...
like the ones not for everyone role
you can iterate through the channels and check if @everyone role has view_channel permissions.
yeah
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
for channels in ctx.guild.text_channels:
# do stuff
!d discord.Guild.TextChannels || not a thing.
No documentation found for the requested symbol.
lol
!d discord.Guild.text_channels
property text_channels: List[discord.channel.TextChannel]```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
this is what you mean ^
Got mixed up with the param
that is called an attribute, not a parameter. parameters are arguments passed into functions
now tht makes sense
I never got that far that is why i said i was editing it lol i got it to work now
Why does my bot keeps saying shit like this
["[]", "["[]"]", "["[]", "[\"[]\"]"]", "["[]", "[\"[]\"]", "[\"[]\", \"[\\\"[]\\\"]\"]"]", "["[]", "[\"[]\"]", "[\"[]\", \"[\\\"[]\\\"]\"]", "[\"[]\", \"[\\\"[]\\\"]\", \"[\\\"[]\\\", \\\"[\\\\\\\"[]\\\\\\\"]\\\"]\"]"]", "["[]", "[\"[]\"]", "[\"[]\", \"[\\\"[]\\\"]\"]", "[\"[]\", \"[\\\"[]\\\"]\", \"[\\\"[]\\\", \\\"[\\\\\\\"[]\\\\\\\"]\\\"]\"]", "[\"[]\", \"[\\\"[]\\\"]\", \"[\\\"[]\\\", \\\"[\\\\\\\"[]\\\\\\\"]\\\"]\", \"[\\\"[]\\\", \\\"[\\\\\\\"[]\\\\\\\"]\\\", \\\"[\\\\\\\"[]\\\\\\\", \\\\\\\"[\\\\\\\\\\\\\\\"[]\\\\\\\\\\\\\\\"]\\\\\\\"]\\\"]\"]"]"]
It also doesn't respond to any commands
Here's the code
@bot.event
async def on_message(message):
if message.guild.id != 891589851110051860 or message.author.id == 897480220133716028:
return
messages = await bot.get_channel(896450664467677225).history(limit=5).flatten()
for message in messages:
save = message
break
try:
lst = json.loads(save.content)
lst.append(str(message.content))
back = json.dumps(lst)
await save.edit(content=back)
except discord.errors.HTTPException:
save = await bot.get_channel(896450664467677225).send("[]")
await bot.process_commands(message)
Can you put multiple images in an embed?
been trying to fix this for the past two hours
dies
No
it doesn't respond to commands because you can only have one on_message with bot.event and you have ovverided it. To fix this, replace .event with .listen(). Secondly, why are you getting the channel each time? Get it once. Also, you may want to make a list.
Only one thumbnail and one image
rip ok
I only have one on_message though?
You can have multiple embeds in one message
no. commands use a glorified on_message
therefore, you break them
just use listen, and remove bot.process_commands
isnt bot.process_commands supposed to fix that?
Yes
who can give an example of a command that solves mathematical problems
@pliant gulch whats the difference between .event and .listen? why doesn't everyone use listen and depricate event. It confuses new users
messier, if you ask me.
Make a list how?
I'm trying to make a bot where everytime someone sends a message, it gets a list from a channel, logs the message into it, and then stores it back. Just in case that matters
how can i make the message event send the message and not the id +++
?
elaborate
it can be done in much easier ways.
uh wdym 💀
Well can you elaborate? How can I do it in an easier way?
be more explicit what do you want to do
This is what I found on docs
.listen
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as on_ready()
.event
A decorator that registers an event to listen to.
There should be no issue about using the event deco
and now i get a time error
@client.event
async def on_message_delete(message):
channel = client.get_channel(904216460010872832)
if not message.author.bot:
async for entry in message.guild.audit_logs(limit=1, action=discord.AuditLogAction.message_delete):
if entry.created_at.now(datetime.datetime.now()):
ModDeleted = True
embed = discord.Embed(title="Message Deleted By Mod")
embed.add_field(name="Member: ", value = message.author.mention, inline=True)
embed.add_field(name = "Mod: ", value = entry.user.mention, inline=True)
embed.add_field(name = "Message: ", value = message.content, inline=False)
embed.add_field(name = "Channel: ", value = message.channel.mention, inline=False)
await channel.send(embed=embed)
if ModDeleted == False:
embed = discord.Embed(title="Message Deleted")
embed.add_field(name="Member: ", value=message.author.mention, inline=False)
embed.add_field(name="Message: ", value=message.content, inline=True)
embed.add_field(name="Channel: ", value=message.channel.mention, inline=False)
await channel.send(embed=embed)```
because there would be no much difference whatsoever. Event uses setattr on the bot instance. So basically event overrides whatever event was set before which I suppose is used for default behaviour like on_message and the commands extension. And listeners are just callbacks that get executed when an event is dispatched.
If you use .process_commands(message)
frankly, I don't understand why you want to do it in this way
please help
and why you want to do it in the first lace
that's spoonfeeding 
if there isn't much difference, which is what I can see - and that listen is better, i don't see the need for event
No much difference in making it general consensus not using it
There's a math module
When i use the message_event i dont want the bot to send text like thislook the photobut the text that someone said
not much point implementing it in the first place, if listen can be used all the time instead, and event confuses people
Show code
well, thats on the devs, nobody can do anything about that other than modify it in their forks
We haven't learn much here, hence why I was asking the creator - andy.
@manic wing this isn't even the same time format they had so how do i fix this?
idk why people ask about something without giving enough context about that
Send message.content, you're sending the message object right now
how do I create an embed so that there are two embeds in one bot message?
You don't
You don't
what don't
ooh
how would I go about doing that?
Install 2.0
I see embeds doesnt exist
@bot.event
async def on_message_event(message):
message_lg = bot.get_channel(#id)
await message_lg.send({message})
Then send a list of embeds
yeah but how do i send the embeds
With embeds=
Like this?
@bot.event
async def on_message_event(message):
message_lg = bot.get_channel(#id)
await message_lg.send({message.content})
!d discord.Message.content
The actual contents of the message.
await ctx.send(embed=embed)
@manic wing are you talking about dpy or @analog dagger s wrapper
Like this?
@bot.event
async def on_message_event(message):
message_lg = bot.get_channel(#id)
await message_lg.send({message.content})
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
oh embeds does actually exist
yeah ty 😄
no need of those curly braces
Without {}
oh okay
andy create dpy...
rapptz == andy
AKA Danny
Bruv
What!?
no lmao
Danny
That's pure bullshit xDDD
lmfao
^
Andy != Rapptz aka Danny
and did you try to ping the other andy
because you pinged the wrong andy
Whos andy
I pinged the right andy

Random dev like any of us here
idk
Yes

I want the list to be able to be visible to my not-so-tech-savvy friends, which is why I can't use a database.
andy is not the dev of dpy so I dont know what you mean by that
dev of Rapptz
lol
lol

I thought he was mistakenly saying 'andy' instead of 'Danny' 
Me too
How do i edit a message after the bot has sent it
message.edit()
Hey can someone help me with this? I get it every time I try to run the bot.
File "main.py", line 1, in <module> import discord ModuleNotFoundError: No module named 'discord'
mess = await ...send()
await mess.edit()
its prolly just a misunderstanding unless he meant something completely different
oh thanks :)
pip install discord.py in your cmd
thx
store the message obj. in a var and the edit it later
Did u install discord?
That is a very rookie error.. are you sure you know enough about Python before jumping into discord.py?
Yeah I just forgot. I have been coding in node.js for a bit. So i needed to gain a bit of knowledge i am just getting back
well then there's discord.js
Yeah I was just wanting to code something in python
is it possible to make it so that there are two embed in one message?!
And does anyone know how to do buttons?
2.0
Use the embeds kwarg
You can only install from GitHub
!pypi dislash.py you can use this 3rd-party package.
@slate swan
thx
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.
ez to use
thank you
where can i find docs on created_at.now
so how do i get it to accept this line?py if entry.created_at.now(datetime.datetime.now()): it didn't specify in docs
created_at returns a datetime.datetime object.
So created_at.now() == datetime.datetime.now().
Somebody help me please I'm Portuguese and I'm making a bot in js, I've entered all platforms to see how to solve it and I just found you, help me take this error out, please this one and the page https://replit.com/join /txerabcm-m4arii
we can't access link


