#discord-bots
1 messages ยท Page 942 of 1
i know
faster?
I mean. Maybe, is checks memory location.
yeah
But itโs not gonna make a big difference
Itโs like a micro millisecond difference
worth it
Suggest more topics here!
Hehe
Message Content Intent Comes To My Mind
Awesome
How can i make a bot that if user have some roles it will return something and if user donโt have that role it will return something
It can run code, I don't think it's unique though
get the member's roles by using the roles property on a Member object, this will return a list of Role objects, after that you can use the Role object properties and check if the role name/id/colour matches your expectations
spam
@slate swan there are only 5 topics for this channel in total according to the source code, you can submit more
You are being rate limited notification is hiding ur msg huh
huh
Oh
I mean
.d
.topic use that hyperlink
Please go to bot commands, thanks
Gg reacted
#bot-commands for a faster switch ...
See
see what
Reactions
Are glitched
no?
Uh
Brad lurking 
We use buttons ๐ ๐ฅ
๐ฟ
We have buttons for a few features, but no one has PR'd one to go through and replace everything
For python bot or sir Lancebot?
I think !subscribe is using buttons right now.-> #bot-commands
Imagine caring about UI ๐ณ
Thereโs so many itโs either going to take a while or itโs a staggered thing
one "should" care about it
I'm a backend dev
Ok
can relate
You're using 2.0 right?
its a replit
..
Well did you install the master branch of d.py?
discord.Embed.Empty recently got removed in 2.0
Oh yea
check dms
huh]
Python Bot's source code is too hard to navigate ngl, doubt someone's gonna replace reactions with buttons
Agreed
there's just dirs and dirs and files and files ||and yes, few are useless||
Not sure I'd consider structuring a bot to be useless lol
but uhhh making the code structure too complex, like, seriously?
I don't think it really is too complex, there's a couple unnecessary things but python is a big bot and it needs a lot of complexity to support that
Unable to convert 'lemme check again before I proceed further and turn out wrong lmao' to valid command, tag, or Cog.
!src
import disnake
from disnake.ext import commands
class confession(commands.Cog):
def __init__(self, client):
self.bot = client
@commands.command(name="confess")
@commands.dm_only()
async def confess(self, ctx, type, message):
# memberitahu siapa pengirim confession, jika anon maka anonim, jika publik maka namanya akan tertampang
if type is "anon" or "anonim" or "anonymous":
pengirim = "Anonim"
elif type is "publik" or "public":
pengirim = str(ctx.author.name + "#" + ctx.author.discriminator)
# mengirim confession
if message is None:
ctx.reply("Kamu harus memasukan sebuah pesan/confession!")
else:
confession = disnake.Embed(title="Confession", description=message, datetime=True)
confession.set_footer(text=pengirim)
await client.get_channel(958714095580897350).send(confession)
await ctx.message.send("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")
def setup(client):
client.add_cog(confession(client))
``` Why is `client` in `await client.get_channel(958714095580897350).send(confession)` undefined?
self.bot, not client
well, i'm adding this to my friend's bot he used client in cogs, but uses bot in main ๐
Well u can use ctx.bot
can you respond multiple times to an interaction?
what to do if the bot does not add discord.py sqlite3 to the database?
how to give role to users by bot?
await add_roles(*roles, reason=None, atomic=True)
read docs
Yes
!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.
Youโฆ can?
how can i get a list of permissions that a user have? like -perms @target
50 pls
not quite you respond to the interaction and if you want to respond to it again you use a webhook
import discord
from discord.ext import commands
import datetime
class confession(commands.Cog):
def __init__(self, client):
self.bot = client
@commands.command(name="confess")
@commands.dm_only()
@commands.cooldown(1, 15, commands.BucketType.user)
async def confess(self, ctx, type, message:str):
print(ctx.author.name + "#" + ctx.author.discriminator + ": " + message)
# mengirim confession
if message is None:
await ctx.reply("Kamu harus memasukan sebuah pesan/confession!")
# mengirim sesuai permintaan tipe confession
if type == "anon" or "anonim":
confession = discord.Embed(title="Confession", description=message)
confession.set_footer(text="โ Anonim")
confession.timestamp = datetime.datetime.utcnow()
await ctx.bot.get_channel(958714095580897350).send(embed=confession)
await ctx.reply("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")
elif type == "publik" or"public":
pengirim = str(ctx.author.name + "#" + ctx.author.discriminator)
confession = discord.Embed(title="Confession", description=message)
confession.set_footer(text=pengirim, icon_url=ctx.author.avatar_url)
confession.timestamp = datetime.datetime.utcnow()
await ctx.bot.get_channel(958714095580897350).send(embed=confession)
await ctx.reply("Confession telah dikirim ke [#958714095580897350](/guild/267624335836053506/channel/958714095580897350/)!")
def setup(client):
client.add_cog(confession(client))
Why does message only contain one word? I used it in different commands it works just fine. I tried did >confess anon this is a confession, but the message only contain this
you need to specify message as a keyword only parameter for dpy's command parser to read more than one word (or always use quotes around the argument)
that worked but the message is in lowercase
it's not case sensitive?
no it should match the casing you write
erm
also your conditions are interpreted as (type == "anon") or ("anonim"), i.e. the latter expression is always true
oh that's why it's behaving weirdly
to compare both strings you can use the membership operator, type in ("anon", "anonim")
Oh heck that concatenation
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
with print, multiple args can be passed too, e.g. print(ctx.author, 'confesses:', message)
Yes but only for print
I remember how I didn't know about f-strings and tried to put multiple args into ctx.send()
Okay but the message is still all in lowercase :?
idk why
ofc in the log it's all in lowercase too
Is your bot set to be case_insensitive
is it legal to use buttons in status
Yeah
oh i didn't check that, this is my friend's bot lol
okk
lemme check
Simple presence integration
alr thanks
The "add server " button?
it's true
There's even a python library for that
no not that
Oh alr
whaa
check my status
Try setting it to False and run the command again
like those buttons
hmhm
I think I can find it for you if you'd like me to
but doesn't that mean my confess command should be all in lowercase, not like COnfEss
Wut abt me 
is this a replit curse? my friend is using replit 
!pypi pypresence @gaunt ice should be that
I am not sure tho
That should but just try
To see if the issue is in that
oh lord, gonna do the funny since he said not to restart the bot, lol
based on dpy 1.7.3 case_insensitive should only affect command names, not arguments
yea
OKK TYSM
Np have fun
Hello
Please do not discuss such controversial and sensitive topics in this server, thanks @unique scroll
excuse me what
they deleted the message
oh
btw does @unkempt canyon have a snipe command?
to check deleted messages?
because that would be pretty useful for moderating
it logs deleted messages ig
okay
Yea...
interaction.followup...
!d discord.Interaction.followup
Returns the follow up webhook for follow up interactions.
Imagine defering and editing ๐
Is discord.py recommended? I see it was made read-only, not sure if I should spend my time learning that or something else like nextcord
discord.py went back into development this march, but afaik it is unclear how long danny will stay as a maintainer
That's what I do. Prevents most of the interaction caused errors
u can try different forks
its ur wish
He will always be the maintainer, but it's unclear, as to till how long is dpy back
I'm pretty noob, trying to do my own project away from following tutorials, so really whatever would be best for a beginner/intermediate is what I'm looking for. This is mostly just for practice
i would suggest just start from discord py
well thats the point, he can stop maintaining it later on
I mean, he isn't liable to keep deving it anyways. Its not like he is getting paid to do it
He does it in his free time ๐คท
Are there any open source bots, or just public repos anyone can point me to? I find reading other ppl's code helpful to understanding things
!src
Best of luck understanding this ๐
Most of the stuff I've done has just been one file, and already struggling with knowing how to structure things
Awesome ty
i mean he stopped maintaining because of discord's direction, so does that mean once the ccommunity is more unified will he just stop again for the same reason
mhm
@vale wing i found the problem, my friend have this in the main file ๐
wtf
yeah wtf, that describes it.
is this just an advertisement or something
Sheeeesh
oof
when i have a queue and have one if query, can i jump back in the queue and do the queue 1 time again
?
is it related do discord bots
just use listen
yes
@spark sentinel Could you provide more info?
nah, i deleted the function, it's not needed
i want in my bot that it do one time the queue ad when its finished, its jumping back and do the queue again
So a task?
no its a queue
In what context?
here it starte, do sth and after its done this it sould jump back to the queue
A queue of..?
how to make a bot dm a specific user
Infinitely?
yeah
member.send()
So... yeah a task.
i dont want it to dm the person who do the command
But why does it need to infinitely loop?
ctx.author.send()
it have to loop back while it checkt all it should stopp
!d asyncio.Queue
class asyncio.Queue(maxsize=0)```
A first in, first out (FIFO) queue.
If *maxsize* is less than or equal to zero, the queue size is infinite. If it is an integer greater than `0`, then `await put()` blocks when the queue reaches *maxsize* until an item is removed by [`get()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.get "asyncio.Queue.get").
Unlike the standard library threading [`queue`](https://docs.python.org/3/library/queue.html#module-queue "queue: A synchronized queue class."), the size of the queue is always known and can be returned by calling the [`qsize()`](https://docs.python.org/3/library/asyncio-queue.html#asyncio.Queue.qsize "asyncio.Queue.qsize") method.
Changed in version 3.10: Removed the *loop* parameter.
This class is [not thread safe](https://docs.python.org/3/library/asyncio-dev.html#asyncio-multithreading).
can i check for author roles in dm_only commands?
Nope
ok
U can only check roles for a Member object and in DM the user is a discord.User object
sounds pretty logical, thanks!
Nextcord and discord.py are 99.9% similar from what I've used at least
discord.py master angry sounds
some things are done fairly differently, most stuff done after about august last year varies a bunch
most notably slash commands
Defo
ahaha
||cringe||
Anything else?
no need, that sums you up
Ashley, keep your opinions to yourself 
how
@bot.command()
async def register(ctx):
cur.execute("SELECT * FROM usersdata")
# hito eito cum here
result = cur.fetchall()
for x in result:
if x == ctx.author.id:
embedVar = Embed(title="ACCOUNT ALREADY CREATED !", description="YOU HAVE ALREADY REGISTERED", color=0x09EAF9)
embedVar.set_thumbnail("https://cdn.discordapp.com/attachments/957544130077143060/957697600138674196/1071-bull-02.png")
embedVar.set_footer(ctx.author)
await ctx.channel.send(embed=embedVar)
else:
registerr = "INSERT INTO usersdata (userid, balance, tag) VALUES (%s, %s, %s)"
val = (ctx.author.id, "1000", "JOBBER")
cur.execute(registerr, val)
mydb.commit()
basee = "INSERT INTO stock (userid, auracoin, silver, gold, tesla, tata, reliance, litecoin, dogecoin, tether, ethereum, bitcoin, bullcash) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
val = (ctx.author.id, 1000,0,0,0,0,0,0,0,0,0,0,0,)
cur.execute(basee, val)
mydb.commit()
embed = Embed(title="ACCOUNT CREATED :ERK__tick:", description="**SUCCESSFULLY CREATED YOUR ACCOUNT**\nTYPE $profile TO CHECK PROFILE", color=0x09EAF9)
embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
embed.set_thumbnail("https://cdn.discordapp.com/attachments/957544130077143060/957697600138674196/1071-bull-02.png")
y = datetime.datetime.now()
embed.set_footer(text=f"{y.strftime('%x')} {y.strftime('%X')}")
await ctx.channel.send(embed=embed)
well
is there any fault in this code
You're pypi isn't async :(
how to stop asyncio.sleep?
You cannot
sure?
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatโs New in 3.10โs Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
you probably cant.
and theirs probably no code for it as it sleeps on the coroutine so you cant execute anything
is it just me or do i see courotine asyncio.sleep(delay, result=None) like a few secs/mins after i saw asyncio.sleep(delay, result=None)
the method is a coroutine yes
this will cause your bot to spam X messages, however if your bot isnt sending anything maybe there's nothing in your usersdata table
Imagine if Python devs decide to change the async and def keywords in Python 4 (ik this is never gonna happen but imagine)
0_o
doubt it i see no term that makes sense other than this one the standard one which is asynchronous define
it was meant as a joke but okay cool

When someone invites the bot to the server, can we send a message to a channel or cmd?
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.
Tysm
Well you can already but why go trough the trouble?
๐ Why everyone thinks I am serious
Well, they didn't specify so I would think that it is a public bot ๐คท
hey guys how can i make my bot to give role to some user who type a specific command. For example, !role
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.
ctx.author.add_roles()
ctx.author.edit()
!d discord.Member.edit
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the memberโs data.
Depending on the parameter passed, this requires different permissions listed below...
probably not the best idea since you cant be sure the inviter or their moderation will like the automated message, especially if it sends to something like an announcement channel
client.run(TOKEN)
File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "C:\Users\jrmev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'
How do i solve this?
TOKEN is not defined.
how to make the bot dm a user with a command
What do you got so far?
How do you define TOKEN
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('defined')
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
client.run(TOKEN)
changed the token
i have that but idk how to make it a command
async def dm(ctx, user: discord.User = None, *, value = None):
if user == ctx.message.author:
await ctx.send("You can't DM yourself goofy")
else:
await ctx.message.delete()
if user == None:
await ctx.send(f'**{ctx.message.author},** Please mention somebody to DM.')
else:
if value == None:
await ctx.send(f'**{ctx.message.author},** Please send a message to DM.')
else:
await user.send(value)
And how does your .env look like?
Also don't define client like that, it should be
from discord.ext import commands
bot = commands.Bot(...)```
Check this tutorial https://vcokltfre.dev
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.
ty
Add a decorator
@bot.command()```
Let's make a new one since this one from stackoverflow is not so good.
For non cog implementation
How is Client/Bot defined?
I also recommend making all the arguments necessary
Too much nesting. Consider moving everything to function level
async def my_command(...):
if something:
do_something()
return
if something_else:
do_something_else()
return
...
lol ye its from there
https://docs.readthedocs.io/en/stable/api/index.html this should be it @slate swan
How can my .json to put in thispy @commands.Cog.listener() async def on_message(self,msg): keyword = (jdata['keyword']) if msg.content in keyword and msg.author != self.bot.user: await msg.channel.send('apple')
How do you define jdata
Is this meant to be an interjection or an abbreviation
Um you know python right?
@bot.command(name="dm")
async def direct_message(ctx, user: discord.User = None, *, text: str = None):
await ctx.message.delete()
if user.id == ctx.message.author.id:
return await ctx.send("You can't DM yourself goofy")
if not user:
return await ctx.send(f'**{ctx.message.author},** Please mention somebody to DM.')
if not text:
return await ctx.send(f'**{ctx.message.author},** Please send a message to DM.')
await user.send(text)
yes
yes?
๐ฟ
Yes it is a lib for operating with json files
How new
2 weeks?
I mean what's your current python knowledge level
10%/100%
Why do people think there's max level of knowledge
It's an absolute value not a relative
thank u
||you're starting to sound like my school teacher||
im getting bot not defined
client if it is
||๐คจ ||
ye
Where are you at rn
output
input
conditions
loops
functions
classes | OOP
hot stuff```
@hollow carbon
I guess so
You can check bot's source anyways
I don't think there's any other way to fetch the docs
im getting this error
@client.command(name="dm")
AttributeError: 'Client' object has no attribute 'command'
Because you should define it like
client = commands.Bot(...)```
And you are defining it like
```py
client = discord.Client(...)```
Check this tutorial out
https://vcokltfre.dev
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.
okay ty
My code only works in vsc, when I run it in default python, only a couple cmds work and some stuff just is reverted, like the !help cmd
Iโm not at my comp rn sto send photos
Well we will be needing the code lol
can some one help me
Is it possible to give someone a role in a forum via a discord bot? And how to?
Yes
!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.
I think he meant on a website.
that method will still be used to add roles lol
the value of the 6th field @stable spire
it cannot be empty or None
A role in a form trough a Discord bot.
yes
Is that question in the scope of discord bots tho? idts
but how to
yes
but how to do that
yes
Then what's stopping you from connecting the bot to the database?
hey would anyone know the methods to join a vc and play an audio file
im not trying to make a music bot that uses music from yt and i'm not using pytube, youtube_dl, etc.
!d discord.VoiceChannel.connect
await connect(*, timeout=60.0, reconnect=True, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
!d discord.VoiceClient.play
play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").
The finalizer, `after` is called after the source has been exhausted or an error occurred.
If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
so do i pass a file path in the source arg
!d discord.AudioSource
class discord.AudioSource```
Represents an audio stream.
The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.
Warning
The audio source reads are done in a separate thread.
alright
Lol
i was confused for a sec because i didnt know what arg was for the vc lmao
what is the hot stuff
how can i check if a user banner is a gif?
!d discord.User.banner
property banner```
Returns the userโs banner asset, if available.
New in version 2.0.
Note
This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
!d discord.Asset.is_animated
is_animated()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Returns whether the asset is animated.
aka user.banner.is_animated() <- True if animated.
You'll need to update because 1.7.2 has no user.banner
okay
yep
U r missing a closing bracket in the lines preceding it
yea
i added it were i thought but it still wouldnt run
tysm
np
and..?
remember that replit uses shared ips so if anyone who has the same ip got api rate limited, your bot may get rate limited too
and it's NOT a host
send the code
also why are you using os.environ.get('')
never seen that before
what does it do?
true

Hello, is there a maximum of dropdown selections that you can have? I currently have 15 options in my bot, and it will most likely even get more, so i would like to know if there's a specific limit.
where
I don't want to interrupt, so I asked my help for a discord bot problem in #help-pie
how can i check if a command is in a message in an on message event?
!d discord.ext.commands.Bot.get_context
await get_context(message, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
Changed in version 2.0: `message` parameter is now positional-only.
!d discord.ext.commands.Context.command
The command that is being invoked currently.
@slate swan
thanks
Maybe with threading or something
i mean, you already have buttons on discord, and tkinter is meh, just very basic gui
There are examples in the repo
where's the repo?
In the pins
!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.10)"). 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.10)") 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.10)") 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**...
i need to do await client.wait_for("message" event from playerlist[message.channel.id][0])
ik that im on the docs for it
Yeah I know...
ah i thought it checked whether my doordash had arrivde
Discord.py is no longer archived? ๐ฎ
Danny resumed the development of it
waaaaaw โค๏ธ
it surely does
def check(m):
return m.content == 'hello' and m.channel == channel
just use lambda

It's literally an example from the docs
Take it up with danny
a suggestion
hey so im basically making an event where if the word 'bot' is in the message content it would send a response, or if i was pinged it would send the same response, and it works fine but when they send another message that does not contain the word 'bot', it still responds as if 'bot' was in the message content
@bot.event
async def on_message(message):
await bot.process_commands(message)
mention = f'@ashen stag'
name = ["bot", "BOT", "Bot"]
if name or mention in message.content:
if message.author == bot.user or message.author.id == 710565634836136006:
return
else:
responses = [
"i was mentioned",
"2",
"3",
"4",
"5"]
await message.channel.send(random.choice(responses))
print(f'{message.author} has mentioned you in #{message.channel.name}, {message.guild.name}')
How can I place the last python version in my req txt file?
requirements file is for python packages not for python itself, i may be wrong though
You don't
!or
When checking if something is equal to one thing or another, you might think that this is possible:
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
@ashen stag ^
thank you!!
I'm not sure if it's the issue but it is an issue
grapefruit is lit
is there a way to get a server member count but excluding the bots?
!d discord.Guild.member_count
property member_count```
Returns the member count if available.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
Changed in version 2.0: Now returns an `Optional[int]`.
is this even allowed to clone channels from a server the bot is in?
tyy
and why in the hell you would want to clone all your channels when template exists
Its a security bot to backup servers, it's just in a testing fase rn
So why not use templates
Donโt know if dpy supports them but no point in cloning a feature that already exists
@bot.event
async def on_message(message):
await bot.process_commands(message)
for word in filtered_words:
if word in message.content:
await message.delete()
embed=discord.Embed(title="", url="", description="Do not send that word!", color=discord.Color.blue())
await message.channel.send(embed=embed)
await bot.process_commands(message)
```
Send a message to message.author
and how is that done? im sorry
User.send
I pretty much said everything you needed
!d discord.Member.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Take a peek
But still, it should be possible
Well there are a lot of things the API doesnโt let you do
I know there are a lot of other backup bots on the web, so trying to make my own one
Take a look at xenon
Iโm just taking a potshot at it might want to check to docs to be 100% sure
Theyโre all obsolete
Are templates in dpy possible?
Might be, check master docs
Just search for โtemplateโ
Iโm on phone or else I wouldโve done it
I still see no point in relying on a bot for this when you press a button and you have your template, and it's way more safe than using a bot
Its a backup, so u can't loose it. I don't know how templates work though
Template links can be stored outside discord also, they're like invite links, so if your server gets nuked or something you can still have a way to restore the channels and roles, what your bot can bring on the table that's better
@client.command()
async def kill(ctx,*,member: discord.Member ,q="Anime Kill"):
api_key = 'supaaasecrettttt'
api_instance = giphy_client.DefaultApi()
try:
api_response = api_instance.gifs_random_get(api_key, q)
lst = list(api_response.data)
gif = random.choice(lst)
emb = discord.Embed(title=q)
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)
await ctx.channel.send(embed=emb)
except ApiException as e:
print("Exception when calling Api")
Errorrr
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: DefaultApi.gifs_random_get() takes 2 positional arguments but 3 were given
can someone help me pls
Read error
And what have i done here api_response = api_instance.gifs_random_get(api_key, q)
Im confused
Why do you define q in parameters though
Define it like ur secret
What's the point
Lol doesnt rly matter but yh
Yo guys I have a quick question
It does?
Ok now i defined it
How
If I set up a few commands and then a message event on the bottom can I make it so that the message event catches only messages that arenโt existing commands or does it already work like that
As far as I'm concerned you don't know to work with APIs tbh
Wdym?
No i do but this is weird idk why its not working where did i give it 3 args
And im asking for help not for validation LOL
how would i make my bot mention me, not like who sends the message but me only
<@urid>
@feral lichen
Or just add your id in the mention
ah ok
what?
I don't know what you're saying demon
Like they showed u
you mean the formatted mention?
<@id>
you mean as i showed?
Essentially to just catch invalid commands and print something
Can someone help me now pls
Kinda big mouth for someone who can't solve a Type error
I mean u could wait for a response from ur bot, if it doesn't respond within ... seconds send that it's not a valid command
There's an error for invalid commands
Lol where these comments from sit down kid
and if you want a command that needs message input use wait_for
Demon, take a step from ur keyboard and keep it civil
Im asking for help not for validation where is that having a big mouth
Uhh how would I do that
can you guys stop.
No

bot.wait_for
There's an error for missing command dude
That's gonna be easier
i have a weapon and im not afraid to use it @Moderators 

Yeah add it to your error handler
Its not for me though
I know
Don't. Just use commands.CommandNotFound
Catch that error
What about reading the documentation of that api, just saying because your error is quite self explanatory do random get take a query?
If i woulduse the search endpoint i would keep getting the same 5 gifs in a random order
Thats why im using the random endpoint
Oh
Wait
Lol
how would i make this await message.author.send("Please refrain from using those types of words!") dm me instead of who sent it
@feral lichen get urself (ur user) and dm it
I figured it out
My bad
Idk im used to using search query not random tag
Nvm same thing
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
could you please further explain
I literally sent the docs
Click on it, look at it
im still confused, im pretty new to it and get mixed up easily
For example
Me = bot.get_user(youruserid)
And then dm 'Me'
so like it'd be await message.me.send("Please refrain from using those types of words!")
What?
No
U had Message.author | Message.author is a member object, just like Me. Now think
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'RandomGif' object is not iterable
@client.command()
async def kill(ctx,*,member: discord.Member ,q="Anime Kill"):
api_key = 'supaaasecrettttt'
api_instance = giphy_client.DefaultApi()
try:
api_response = api_instance.gifs_random_get(api_key, q)
lst = list(api_response.data)
gif = random.choice(lst)
emb = discord.Embed(title=q)
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)
await ctx.channel.send(embed=emb)
except ApiException as e:
print("Exception when calling Api")
Line?
File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 309, in kill
lst = list(api_response.data)
TypeError: 'RandomGif' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'RandomGif' object is not iterable
U cant just make a list of it is what it says
im still confused, is there a chance you could send it ina code example instead?
Oh
Ah ye its random forgot
@feral lichen what was your original issue?
#i pretty much told u everything
me = bot.get_user(yourid)
await me.send('blablabla')```
This was pretty simple to understand
i tried that and it didnt work idk why
What did u try?
for the (yourid) part do i put it in 'id' or like
i know
Send the code u tried
me = bot.get_user(842756567527063582)
await me.send('test')
And how does it "not work"
doesnt dm me 'test'
Any errors?
bot
Send ur full on_message event
Where is that snippet in terms of the rest of your code?
Yeah
How do I handle inputs with command ex: !example input
bot.wait_for
Let it wait for a message, save the message in cache as a variable and done
@feral lichen
If itโs in the same message like that will there be a space at the beginning or will it be fine
{'data': {'fixed_height_downsampled_height': None,
'fixed_height_downsampled_url': None,
'fixed_height_downsampled_width': None,
'fixed_height_small_height': None,
'fixed_height_small_still_url': None,
'fixed_height_small_url': None,
'fixed_height_small_width': None,
'fixed_width_downsampled_height': None,
'fixed_width_downsampled_url': None,
'fixed_width_downsampled_width': None,
'fixed_width_small_height': None,
'fixed_width_small_still_url': None,
'fixed_width_small_url': None,
'fixed_width_small_width': None,
'id': 'l49JC3Xl5HZj4JJxm',
'image_frames': None,
'image_height': None,
'image_mp4_url': None,
'image_original_url': None,
'image_url': None,
'image_width': None,
'type': 'gif',
'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm'},
'meta': {'msg': 'OK',
'response_id': '147a5b3ce0c602ed33e4d788053401cd7a01b285',
'status': 200}}
output of the api which has a id
File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 312, in kill
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
AttributeError: 'InlineResponse2002' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'InlineResponse2002' object has no attribute 'id'
it saying it doesnt have id
@client.command()
async def kill(ctx,*,member: discord.Member):
api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
api_instance = giphy_client.DefaultApi()
try:
api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
gif = api_response
emb = discord.Embed()
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)
await ctx.channel.send(embed=emb)
except ApiException as e:
print("Exception when calling Api")
code
In the same message, add parameters
@bot.command()
async def foo(ctx, arg):
await ctx.send(arg)
usage: <prefix>foo <argument>
What do you think when reading that error
That it says it doesnt have a id
What does that mean?
That the api didnt respond with a id
Send full traceback
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Yuki\Desktop\KyuuMainPy\r34bot\main.py", line 312, in kill
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
AttributeError: 'InlineResponse2002' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'InlineResponse2002' object has no attribute 'id'
!e
my_var = ""
my_var.id
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'str' object has no attribute 'id'
Is it a dict?
The gifs variable is gif
He probably wants to slice the dict
Send the gif variable
Is it the dict u sent at the start?
@client.command()
async def kill(ctx,*,member: discord.Member):
api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
api_instance = giphy_client.DefaultApi()
try:
api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
gif = api_response
emb = discord.Embed()
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)
await ctx.channel.send(embed=emb)
except ApiException as e:
print("Exception when calling Api")
Is it this?
'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm' just watch the url sample tho
async def on_message(message):
await bot.process_commands(message)
for word in filtered_words:
if word in message.content:
await message.delete()
me = bot.get_user(842756567527063582)
await me.send('test') ```
U cant just take an id from an api response demon
U can make it a json and slice 'id' out of it
I tried writing it
Yeah it wont have an id attribute
Bot.process_commands should ALWAYS be on the end of the event
!e
my_dict = {"data": {"id": 123123123}}
print(my_dict["data"]["id"])
@final iron :white_check_mark: Your eval job has completed with return code 0.
123123123
@lucid vine
he uses a bad wrapper as i can see, he doesn't directly call the api in the code
Same thing with api, format the api response into a json, slice it
Not sure how i do that in my case
huh, so like move it to the end?
The end of the event yes
async def on_message(message):
for word in filtered_words:
if word in message.content:
await message.delete()
me = bot.get_user(842756567527063582)
await me.send('test')
await bot.process_commands(message)```
Don't mind indents, I'm on phone
It's literally the exact same thing. Imagine my_dict was your API response
you need to process the commands above, if you put it at the start idk if it even has any effect
It has to be at the end
well, that's what i said
Oh mb, I read that wrong
Nope dont get it
I thought you said u didn't know if it had any effect where u put it
Have you ever worked with dicts before?
No
Might wanna learn basic python first
I know python lol not json
lmao
A dict is a list with instead of an item, a key and a value
That's your issue
dicts/json are basic stuff if you work with APIs
Ah i see ok now but how
Do i get my api response into a dict
It will return a dict
When you make a request to the API it should return a dictionary
!e
my_dict = {"json":"No", "python":"yes"}
print(my_dict["json"])
print("____________")
print(my_dict["python"])
@rocky trench :white_check_mark: Your eval job has completed with return code 0.
001 | No
002 | yes
In the brackets, u include the key. It will return the value
No
No
Its not a dict yet.
man it still doesnt work
Not sure if u have to import json. But u need to format it using object.json()
How does object.json work
Send error if there are any, else send code again
I have json imported for custom prefixes
Hmm?
There is another way too, but I use .json()
If you make a request to an API endpoint it should just return the JSON
Yes i know that
there was an error after i tried the event.
You don't need to?
But then how do i make it a dict
Ur bot didn't get the user. Does it have intents?
The API should return a dictionary
When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says
@bot.event
async def on_message(message):
for word in filtered_words:
if word in message.content:
await message.delete()
me = bot.get_user(842756567527063582)
await me.send('test')
await bot.process_commands(message)
{'data': {'fixed_height_downsampled_height': None,
'fixed_height_downsampled_url': None,
'fixed_height_downsampled_width': None,
'fixed_height_small_height': None,
'fixed_height_small_still_url': None,
'fixed_height_small_url': None,
'fixed_height_small_width': None,
'fixed_width_downsampled_height': None,
'fixed_width_downsampled_url': None,
'fixed_width_downsampled_width': None,
'fixed_width_small_height': None,
'fixed_width_small_still_url': None,
'fixed_width_small_url': None,
'fixed_width_small_width': None,
'id': 'l49JC3Xl5HZj4JJxm',
'image_frames': None,
'image_height': None,
'image_mp4_url': None,
'image_original_url': None,
'image_url': None,
'image_width': None,
'type': 'gif',
'url': 'https://giphy.com/gifs/the-jellies-l49JC3Xl5HZj4JJxm'},
'meta': {'msg': 'OK',
'response_id': '147a5b3ce0c602ed33e4d788053401cd7a01b285',
'status': 200}}
Thats the dict that it gives me
But
Thats just the api response how do i make that dict now
Do you have intents enabled?
Show me your code
@client.command()
async def kill(ctx,*,member: discord.Member):
api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
api_instance = giphy_client.DefaultApi()
try:
api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
lst = list(api_response)
gif = random.choice(lst)
emb = discord.Embed()
emb.set_image(url=f'https://media.giphy.com/media/{gif.id}/giphy.gif')
emb.add_field(value=f"{ctx.message.author.mention} kills {member.mention}", inline=True)
await ctx.channel.send(embed=emb)
except ApiException as e:
print("Exception when calling Api")
When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says
on replit? is so i dont think so.
In discord developer portal and in ur code
Show me how you're printing the dictionary
Go to ur bot dashboard and enable it
I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that
client = command.Bot(command_prefix= "_")
api_key = 'jYrhiVnoJ1ggfduvL4TBsbMwPlqXpN1N'
api_instance = giphy_client.DefaultApi()
api_response = api_instance.gifs_random_get(api_key, tag="Anime Kill")
gif = api_response
print(gif)
Yeah so api_response is your dictionary
in discord developer idk where but would i have to import something in the code?
Spoonfeed time
The args intent i think and the dashboard for intents
Try accessing the id with
api_response["data"]["id"]
tbh, you just should make a get request with aiohttp and then extract the info you need from the json you get as response
TypeError: 'InlineResponse2002' object is not subscriptable
I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that
Alr but now i wanna finish this what ive started
Print the type of api_response
Oh my god. Honestly, just stop supporting if the person that needs help doesn't know what they're talking about
In dpy its a much more strict rule, no basic python? Get yo ass out
Hello
Hello
I need some help When someone types Hello. I want it to send an embed message with buttons and depending on the button they pick is what the bot says how do I do that
yeah idk where that is
how you even made a bot then? discord developers portal
Can you stop spamming?
Can someone help me
on_message event, check if message is the thing u want it to be, send a message with buttons and done
U can find everything you need on dpy GitHub and the docs
print(api_response["id"])
```?
Im confused
Bruhhhhh
ik discord developer but im confused where you mean in the discord developer portal to intents or sum in the code
No, the type of api_response
The TYPE
tbh, they be like ?tag abcd on every question and that's it
Oh type()
The tags explain it more than enough
intents needs to be activated from both, code and dev portal
Wizguy, please just read the docs. Its all in there, we won't spoonfeed.
<class 'giphy_client.models.inline_response_200_2.InlineResponse2002'>
Thats what i got
oh god

@final iron it's basic python, at this point we can clearly see he or she doesn't know enough of it.
Okay let's rewind. What are you even trying to do in the first place
the spoon should stop feeding 
So yh im trying to get the api to give me the id of the gif so i can send it in a embed
Tried reading the docs of the API wrapper you're using to see how to do it?
Yes ive read them
Willing to send the docs?
Yh 2sec
The GIPHY Developer Portal is how you integrate the world's best GIF API into your business, app or project.
Can you send the docs on the specific thing?
Ngl python discord should make a rule to know basic python as well
The GIPHY Developer Portal is how you integrate the world's best GIF API into your business, app or project.
Not gonna be rude but who is talking to u
Wrong
Message
Meant @rocky trench
I'm talking to pep8 that he should stop helping you, since you don't know basic python
U have said the same thing 10x and no one reacted
That's the bare minimum. Learning basic python
Only takes a week if you're fast, tons of apps and sites for it
Yh nvm no need in wasting my energy
It is needed, cuz pep8 is spending over 10 minutes to help you with something you could've known in under 30 seconds with basic knowledge
sadly many people come here daily without bit of knowledge of python and try to do crazy stuff, damn
Then I'll be ignoring you too from now on. And I hope everybody does, cause you act like a baby that only wants spoons
At least they try to understand. This guy is waiting for his spoon to arrive in his mouth
LOL saving a id of a api response to a dict then reading from it is crazy stuff
That's just stupid
Oh da chat moves on its own
I do want help
Take some knowledge and you won't even need help
I dont like u i dont want ur help
Then don't try to act 'cool' and act like I'm invisible
Ur arrogant and full of yourself?
LOL cool i was just trying to make it clear to you that im ignoring you
So you dont continue wasting your energy
Full of myself? No, I say what needs to be said. In dpy discord you would've had people about 15 times worse than me
why would you even want to save the id, you just need the url of the gif so you put it in .set_image literally, at this point is common sense tho
Guys, please stop
I am saying u need to learn basic python, but you're too lazy. U expect to learn to code by spoonfeed?
Keep it civil
Im just trying to ask for help
Yeah and that's alright. But at least do some research and try to understand what we are saying instead of waiting for a spoon to arrive with all the information on it
Yes, but knowing a certain amount of Python will help you out. Now ask your question without being condescending
But the url shouldnt be the same
Thats why im using the random api endpoint
Its a random url. He needs his api response into a dict, and slice 'id' out of it. Simple as that
both of you are out of line
Now google 'how to get a dict out of an api response' and 'how to slice a dict python'
Yes and im asking for help to get that api response into a dict?
you too
Its simple as this...
Unless it's XML
mhmm
Yes but i couldnt read from it
that's not a dpy question anymore
Or raw data, octet streams, x-www-form-urlencoded, etc
I'm trying to help him and saying he needs to start learning basics, he actively refuses so I tell him people won't spoonfeed him. I don't see what I'm doing wrong.
99% it will be json with the option to get XML too
Yep
specifically the msg I replied to an your overall tone as well
json is the gold standard for APIs
Alright, that message was a little to aggressive but he was starting to make me mad.
I would highly prefer if we guided users to #โ๏ฝhow-to-get-help if their question is not bot specific
Mostly because a lot of APIs are written using javascript, and well, javascript object notation
^
if you notice that, that's a good sign to step away :)
My question
Was bot specific
Yeah. Will keep that in mind
Api isn't bot specific ๐
speaking of APIs, I wanna try GraphQL, but off topic
I was getting dpy errors at the start
The api is part of ur bot, but it's not part of discord bots library's
At the start yes, but this problem is the api now.
I cannot finish resolving my issue in the same channel because someone is mad about me not understanding??
Lol
Because it doesn't belong here
PEP8 ๐ฟ
He still doesn't get it.
But i started resolving my issue here
Both of you give it a rest before this channel gets locked or you get muted
walk away
Yeah but now you should go to a help channel, because the problem you are having now is api based
I think at this point, you'll get better help in a help channel. that's my recommendation
why the people who are always here helping people are scolded but when someone rude comes in without minimal knowledge it's just ok
I only scold rude people
When was i rude?
!silence
โ silenced current channel for 10 minute(s).
as I was saying, moderators will only "scold" people when they are being rude or otherwise not following the rules
we will not take a user's skill level into account. both beginners and expects can be rude, and in both cases it is not allowed
let bygones be bygones
at a glance, I agree @lucid vine that your problem currently isn't a discord bot problem, if it's on how to parse an API response. I highly recommend you move to a help channel #โ๏ฝhow-to-get-help
everyone else: no need to be rude, or admonish for someone even if you perceive them as wanting spoodfeeding
be kind with your help, your redirecting to other channels, or don't participate
I think that's a reasonable expectation for us to have of you
if in doubt, let the #rules and #code-of-conduct guide you
!unsilencr
!ubsilence
lmao
!unsilence
โ unsilenced current channel.
Epic talk
carry on, keeping what I said in mind please
Hey! Could somebody explain to me why, if i send a link, more specific a link to a twitter post, via a discord bot with await channel.send, the link gets just posted as hyperlink instead of the little embed it would create when i just post it regularly in discord?
Maybe your bot doesn't have image perms
He has admin perms, on my test server, so i think thats not the issue unfortunatly
If you post that same link yourself, do you get the embed?
๐
And how does the bot post the link? In an embed or in a normal message
In a normal message, but so do i if i just copy paste it into discord and it still builds an embed
oh
Yo if I put a check inside a wait_for is an error raised orrr
Can u send the code?
Not sure if it has anything to do with it, probably doesn't
Only if a user fails to respond within the allocated time
Is it possible to make it print something else if the check fails
Sure. the wait_for check only cares about a returned true/false value
you can have side effects within the check like printing
I just found out that for some reasons sometimes it DOES embed the tweet and sometimes it doesnt
Like print inside the check function?
Sure
Any idea what could be the cause for it sometimes embeding and sometimes not?
Probably on twitter's side. For the embed to show up you need a special <meta> tag, and depending on how twitter does their rendering, it can be spotty
(CSR vs SSR for example)
Wow i have no idea what that means
But there is a different bot that does the same that mine does and it shows up as embed everytime
I'm not going to get into that as that's vastly out of the topic of this channel, but I would be happy to explain it to you somewhere else
XD
mine had 1 out of 4
Is it the same link?
no
Still from twitter?
yeah
I see. Maybe just a problem with that specific tweet
Also it looks like all of those are different links
Different users maybe
Ohhh no now i see
if its a retweet ot doesnt embed, for normal tweets it does
now i need to find a way to exclude retweets
If I do message.author itโs just the uid right?
no, it'll return Member object
h
if you want to get author's id, use message.author.id
how can I get 2 arguments from a command
What?
You mean like adding a argument to a command?
example arg1 arg2
is which one is which indicative of which order I add them or something
what does this mean?
example arg1 arg2
He wants 2 arguments in his comand
ok. pass two parameters to the function
๐ฟ ๐
The order of which argument you passed in the parameter that's the order of what argument you have to give
ok thanks thats all I needed
Okay
how do i fix this?
@commands.command()
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.voice_bot is None:
await voice_channel.connect()
else:
await ctx.voice_bot.move_to(voice_channel)
U already in voice channel?
yeah i was in a voice channel when i sent that
what is even voice_bot
Yeah
i thought it was supposed to check if the bot is already in a voice channel?
!d discord.VoiceClient.is_connected
is_connected()```
Indicates if the voice client is connected to voice.
better check docs rather than guessing
what's ctx.voice_bot?





