#discord-bots
1 messages Β· Page 1133 of 1
thats like saying discord.py and discordpy its the same title
Hi. Iβm very embarrassed to talk about it, but after spending several hours studying what is written in this link, I couldnβt get anything. Can you please help me to sort out this problem?
!pip discordpy
u just make a .env file in ur root directory ( root being the directory in which you have your main file which runs ur bot ) then inside that file you write PYTHONPATH=name of ur directory and ur linter will recognize that directory as the root directory
ok and
dpy 
we cant really argue as the name of parent folder is discord
and not discordpy
with my role it looks like this duck as an umbrella hat lol
cute
lemme ping danny and get banned rq
they will just see you typing and they would ban you instantly
unfunny
idk
no
Yo I need help with a bot
no, lets not give him that position
python wasn't made by a single person smh
guido van is the creator of python lol
no
probably not
i mean he is
nvm
actually he is
well he is i agree
?
are you talking about guido or danny? 
danny
created a class.env file in the bot_py folder. there I have a bot.py file that launches the bot.
I write PYTHONPATH = ???
who else am i talking about
ryuga i saw that
π³
then put the name of the directory which has ur cogs
please no π₯Ί
π
I couldn't read that in time π
good person, cares about online environment
π€
thanks
if you made the code, you should make the tests as well
but you're clearly uwuer
π³
im pretty sure you can make a partially created obj with that info
await channel.send(embed=embed)```
help pls
channel returns None
I wrote PYTHONPATH = cogs.clas because all classes are in this folder, however, after reinstalling VSC, the line was preserved
wdym by that
π
arllll
smh imagine leaving disnake
okimii means that channel = None and None.send isnt a thing
totally me, I don't use disnake anymore ps I wasn't active in that server sooo
you would write it like cogs:clas
Crap. still doesn't work.
hmm, then i don't really know, you can ask in #editors-ides or VSC support
show code
consider using CREATE TABLE IF NOT EXISTS if you are not already doing that
:)
that is only what gets executed
might sound dumb but did you commit?
but integer works fine enough? is there any specific reason?
cz integer only works fine for sqlite iirc
Well thank you
read an .sql file and execute everything that is inside it :)
overkill...
syntax highliting 
do they?
yes integer works fine
meh who cares
not me
i was gonna ping you lol
german moment
stop it smh, just remember when I say meh am not referring to you, but when I say handsome meh I am honestly referring to you
Hi!
Uhhhhhh how do I define a Variable depending on a Message?
Example: I have a Message in My Server which contains "215". How do I define a Variable in a Script to sync with the Value of this Message?
"sync"?
synchronize
do you have an "on_message" event set up?
no just @bot.command
"synchronize"?
what exactly are you trying to do
Meaning what are we syncing and how.
uhhh ye, like if I edit this Message it should sync the value of this Message to the Variable assigned to
I'm new sorry xD
!d discord.on_message_edit
discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events 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/latest/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
!d discord.on_raw_message_edit
discord.on_raw_message_edit(payload)```
Called when a message is edited. Unlike [`on_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message_edit "discord.on_message_edit"), this is called regardless of the state of the internal message cache.
If the message is found in the message cache, it can be accessed via [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message"). The cached message represents the message before it has been edited. For example, if the content of a message is modified and triggers the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") coroutine, the [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message") will return a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") object that represents the message before the content was modified.
Due to the inherently raw nature of this event, the data parameter coincides with the raw data given by the [gateway](https://discord.com/developers/docs/topics/gateway#message-update).
but what's the end goal
To be able to edit the Message in Discord, and when you've done that the Code automatically puts this value into the Variable
like:
TheVariable = TheValueOfTheMessageOnDiscord
Example is if the Message on Discord is "12345", then the Variable should be "12345" as well
But how do I define which Message?
async def verify(ctx):
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete()
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)``` why isnt this working i just dont understand it
problem: it wont do anything
do you have an on_message event
/ if no: do you have an error handler
/ if no: is this command above bot.run
yes
π which one?
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
else:
await bot.process_commands(message)```
i dont have an error handler
yes it is above bot.run
remove that else part completely
wait why
and change .event to listen()
okay
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
```like this right?
.listen()
oh
so it still isnt working?
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
@bot.command()
async def verify(ctx):
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete()
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)``` this is how it looks alike rn
can you try adding some print()s to check where the code stops working
what do you want me to print out?
anything you want, just for an idea to see what parts of code gets excecuted
wait do you have an on_command_error event?
no i dont
why not just use a button?
just add a print statement inside that command which prints "command executed" to see if the command runs or not
^ this will make it much more easier, a persistent view which verifies the user on clicking it
persistent view is a view that never timesout right?
yep
i already have that
yes it prints works
Yesn't
hey guys helpp
i wanna join my bot in a voice called office
and i use this cmd:
async def join(ctx):
channel = ctx. author. voice. channel
await channel. connect()```
and i join a vc and i use that cmd
here is eror :
next(iterator)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
await self.process_commands(message)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 693, in _parse_arguments
raise discord.ClientException(fmt.format(self))
discord.errors.ClientException: Callback for join command is missing "ctx" parameter.
You're missing the self parameter, which should be the first parameter of the method
umm
better ?
async def join(self, ctx):
channel = ctx.author.voice.channel
await channel.connect()```
@magic ore
not wroking
Hello, I'm making a discord bot that reads and writes some data to a text file, is there a way I can make it so once the amount of lines is greater than 15, it deletes the top line before adding another line, so it only stores the most recent 15 values (if that makes sense)
you can get the length of the file using readlines, like len(file.readlines()
readlines() returns a list of all the lines in the file
so what you can do is if the len is 15 you pop the first element of the list and append ur new entry to it
then you join the list and write it to the file
hi how can i fix?
Your screenshot doesn't include the actual error
Also, you can just paste the error. Don't bother with screenshots. They're not preferred anyway.
mark can you help me?
I'm not familiar with that interactions library, so no, sorry.
can you recommend a good one?
I'm remaking the bot from scratch, in time for a change
Not really. I haven't used interactions much myself. I know discord.py's alpha version supports them.
that of rapptz?
You'll have to get advice from someone more experienced with interactions. I'm the wrong person to ask
Yes
is there still no way to see if a link button is clicked
nope
no as its outside of discord
unless u own the link
how do u wait for message discord py
It might sound dumb but try to change the name of ur function to something else
wait_for
!d discord.ext.commands.Bot.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/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
I think you're looking for this π€·πΎπ€·πΎ
There is a check
It does work π€
Wym by the correct message
Maybe u did something wrong or something idk
Ye
any help?
Looks like somethings wrong with your DNS server
Try restarting it
Won't work
Might be a discord shortage then
I have a great Idea for a Discord bot
So basically it will be a phone.
I know that may sound stupid at first but listen.
So it will be that way that if you can go into a waiting room and then call a real number by something like !call +1 123345453.
Then it will move you and call the number over a VOIP API which leads you to be fully anonymous if you also use a spam Discord account.
It would be kind of expensive tho
or do the same thing cheaper and safer?
Whichever works π
worst idea I've seen yet
how
privacy issues
?!
I mean, how does the api call numbers?
random.randint and while True go brr
well even if that works how's the command invoker gonna talk
so then you'd have the same number calling different people at the same time
or will you have to input your number
or auto-buy a SIM card for each user?
idea is just confusing :P
all for your silly little Discord bot :P
which no one's ever gonna use
hits hard
Hi
How to make a custom activity in a bot?
Hmmm . I looking a fun thing on google
try a "guess the number" game
check pins
I have that using python once but now in dpy
its the same....
thanks
Nobody would play it
bad excuse for not wanting to make it huuh
It's easy i can make it but it should make my bot little more good
Tell me any good one that my bot users would like to play
tic tac toe
using buttons
Let me try it
I'll give you a fun thing to keep you occupied for days if you would like
even im making that rn
go ahead
mehh, nvm, is kinda dub
...
jus tell us
Fight command?
something that like keeps a check on specific user and messages
more like stalking
^
exactly
That's fucking dumb
fr
The internet is dumb*
you are dumb*
css is dumb
Why would a bot behave like a thief?
stalking != act of theft
Stalking == grand theft
me != not a thief
everybody is*
Me a lot dumb
meanwhile @unkempt canyon deleting txt files but not this
it's a work of art
π
π³π
π΅βπ«
alr this channel will be renamed to flirting-zone
ash is just jealous
doesn't matter π³
Whats gay?
Hmmm i should I use my discord bot to ask about this word
π’ lmao
nah am fine
Let me go and use the define command
.
lets move on from this topic before some mod bonks our head
bruh
.topic
Suggest more topics here!
if you want something more challenging that a bot but related to the discord api make an api wrapper lol
make an api instead.
/capybara
oki
π©
"bonks" π remain pg 13 sarthak
Make a cooking thing
oh that
ash you're the non-pg-13 one
whats the non-pg-13 of bonk
Try it with slippers
it is what it is, I just got good english
ok boomer
we are to remain pg 13 here
remain pg-13
boi what the hell boi
Anyway get to the topic
.topic i didn't do anything
Suggest more topics here!
https://deploy-preview-732--pydis-static.netlify.app/pages/guides/python-guides/bot_presence/#how-do-i-get-these-statuses-and-activities-for-my-bot
@slate swan fix the md ;-;
In depth tutorial on how to set all available presence to your bot!
gib voice rec
skill issue
your skill issue
so are we like... supposed to parse (and render) the markdown in our head
yup
Guys can discord bot record voice?
yes, but not with plain discord.py atm
yeah, discord.py doesn't support that tho
i have no skill issuesπ³, infact i have no issuesπ΄οΈ
Is there any 3rd party library fir it?
use discord.js, no but some forks got it
make command that simulates jiggle physics
just use py-cord djs
Lazy to convert my bot to pycord
I hate java
I don't think DJs know how to code
Java is not JavaScript
and java is our lovely language β€οΈ
;-;*
They would be more interested in remixing music
asher is gone <3
@shrewd apex wakie wakie
Don't ping
who cares i dont
Mayhe he school
@shrewd apex wakey wakey, is time fo schoo
dont disturb him, hes sleeping, with me
rip
I forgot its sunay
can i join
asssserrrr
?
I dont like sleeping
asher*
asher wanna play coc?
i love sleeping but can't
anyone wanna play clash of clans?
coc
clash of clans?
Nah
yup
Play free fire with me
i used to play dropped at th13
I'd rather not use Clash of Clans' abbreviation
robin stop stalking us
wanna make a clan?
bruh #discord-bots
i mean
Robin has been caught
@slate swan want to play free fire with me?
robin, π I made changes to the pr
(if you read this)
nah, you trying to play clash royale tho?
heeheeheehaw
Thank you. Iβll check it out once Iβm back home
i played all super cell games except boom beach and hay day
you arent leaving my house
what day
oki doki, have a safe trip back home
lmao
hay day is the best game
thank you π
copyright.
bro
ok i am gonna go back and study cya
bai bai goodluck
bye asher, gl.
dedication makes you close discord ots, totally not me
Good luck for study
i thought that said "good luck daddy"
π
π
down bad brother

Wtf
Bro Iβm so good at it
go touch some grass, champ 6k πΏ
hm.
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
else:
await bot.process_commands(message)
@bot.command()
async def verify(ctx):
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete(delete_after=3)
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)
```why isnt this working i just dont understand it(the bot.event works)
it doesnt give an error in the console
but the problem is it doesnt send the message neither adds the role
nvm
are you using Client or Commandsbot
like bot = commands.Bot
or something else
@swift pumice
yes im using bot
you did two intents
bot = commands.Bot(command_prefix=(["!","E!"]) , case_insensitive=True)
@bot.command()
async def verify(ctx):
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete(delete_after=3)
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)```
```py
@bot.command()
async def verify(ctx):
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete(delete_after=3)
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)```
i mean it could be since you're trying and it's not working
okay
did it work?
no it didnt
can you show me what are you typing to execute the command
!verify
wait
problem, my event triggers
yes, but my problem is rn, if i write !verify my bot.event triggers and not my command
if you're trying to make a verify command that just triggers the basic things, you can use a normal on_message event for that no need to make two different functions for a command
oh
how long does it take to loop through 5k members
how would it look alike then?
you can remove bot.coomand
okay
depends on the internet
that isnt really predictable.
hardly 10 seconds imo
π
but depends on your program's load
exactly the same as before
what
what
his bot.command was not working because he was using client.event to check if that command triggered correctly
1ms
nice
way out of my understanding
prolly cuz my english is sh*t
nah, I just mean the logic behind doing that stuff
.
@swift pumice when you type the command, does it get deleted?
yes
i didnt test it, just guessing :p
then sends my message
just take the code from your command and add it to on_message ig
you're smort
let's make it 2 ms for me plz π
can i use for guild message? like message.guild.get_role
no lol, make a variable for that
ok
guild = get_guild then role = guild.get_role
async def on_message(ctx,message):
if message.author == bot.user:
return
if message.channel.id == 987651665492586568 and message.content.lower() != "!verify":
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
else:
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete(delete_after=3)
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)
await bot.process_commands(message)
@slate swan
like this?
if message.channel.id == 987651665492586568 and message.content.lower() == "!verify":
role = ctx.guild.get_role(985205310740389918)
await ctx.author.add_roles(role)
await ctx.message.delete(delete_after=3)
await ctx.send(f'{ctx.author.mention}you are now verified', delete_after=3)
await bot.process_commands(message)
else:
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)
thanks
make sure to add intent to that role
ok
okay
from dinteractions_Paginator import Paginator
ModuleNotFoundError: No module named 'dinteractions_Paginator'
``` can someone tell me why is this happening ??? when im using replit it isnt a problem
remove the ctx from your bot.event(ctx,message)
okay
wtf is wrong with me
replace it with?
if message.channel.id == 987651665492586568 and message.content.lower() == "!verify":
role = ctx.guild.get_role(985205310740389918)
await message.author.add_roles(role)
await message.delete(delete_after=3)
await message.channel.send(f'{ctx.author.mention}you are now verified', delete_after=3)
await bot.process_commands(message)
else:
await message.delete()
await message.channel.send(f'{message.author.mention}please only write !verify and not something other', delete_after=3)```
it should work now
thx
^
it takes 6ms
it will take 2 in hikari π
!pip dinteractions_Paginator
Official interactions.py paginator
thats not how you import it, checks the docs they show how you do it
hikari ftw
nice shit lib
Hi
Hello every, so I have a question, the question is how can I make a button and when the user clicks it, bot will response some question for you in the private message, at last, the private message will content direct to my discord server and bot will make a Embed Editor, How can I make this ?? (.py)
thx
"content direct" and "embed editor"
elaborate
and which library?
you can't open links for people
I mean, run programs on the client side
π€
how to dm the mentioned user
guys help
im coding in replit
and this is main.py
import asyncio
import os
import random
from discord.ext import commands
bot = commands.Bot(command_prefix=["p!","P!", "puppy", "Puppy"])
bot.remove_command("help")
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="Spotify"))
bot.load_extension("commands")
bot.run(os.getenv("token"))```
Hey @warm tulip! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
whats the problem
idk
eror :
Traceback (most recent call last):
File "main.py", line 20, in <module>
bot.run(os.getenv("token"))
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/yoohooool/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
the bot dosent start
well it depends on which tasks will be executed per member, if theyre O(n) and if a task can block asynchronous tasks
youre being ratelimit if its replit do kill 1 in your terminal to kill your container
put this at the end of mainpy
try:
keep_alive()
bot.run(token)
except discord.errors.HTTPException:
print("\n\n\nBLOCKED BY RATE LIMITS\nRESTARTING NOW\n\n\n")
os.system("python restarter.py")
os.system('kill 1')
ew
and make a file called restarter.py
from time import sleep
from os import system
sleep(7)
system("python main.py")
put this in restarter py
hhow do i dm a mentioned user
!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/latest/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/latest/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/latest/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/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
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/latest/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/latest/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/latest/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/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
can you come in dm so i can send u replit invite link plss
same thing though sooo
not really
whatever smh
thats like saying a blueberry is equal to a strawberry
hi how can i fix?
What do you mean
btw do you know what Iβm talking aboutοΌ
sorry my english is bad
kind of
what your get ??
wont get much help here since third party lib
I dont get what you mean by "content direct" and "embed editor"
Β―_(γ)_/Β―
you recommend a good library that includes the Slash command and embed
discord.py or hikari
hikari is complex though
!pip discord.py
!pip hikari
I still prefer hikari
includes the Slash command
it keeps saying
BLOCKED BY RATE LIMITS
RESTARTING NOW
Ok thanks
1.7.3 doesnt have app commands lol
ok so content: I would like to directly deliver all DM messages to the discord server
okimii your intelligence fucks me up ngl
how so?
you just say the obvious every time π
I mean I do know that 1.7 doesn't have slash commands
then why recommend it?
ποΈποΈ
I recommended discord.py smh, sorry godling
you ment 2.0?
can i dm message author and the person they mentioned?
like author's dms = "message send"
mentioned dms = "hello"
!d discord.ext.commands.Context.author
Union[User, Member]: Returns the author associated with this contextβs command. Shorthand for Message.author
embed editor
!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/latest/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/latest/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/latest/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/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
this @slate swan
its the same as ctx.send
@slate swan content direct : I would like to directly deliver all DM messages to the discord server
just dm the author of the context of the command, that the message was sent and then have an argument that expects a Member object and then just use Member.send
@slate swan Do you get it???
oh god
Just use the on_message listener and check if the message was sent in the bot's dm then get/fetch the required channel and use the send method on it
I don't know what embed editor is soooo
embed editor thisssssssssssssss
what do you want to do with that editor?
you can't make someone use an embed editor for custom embeds, it either generates a code for some langauge, or the embed payload ( this can be useful )
you can use Embed.from_dict(payload) for them to create a custom embed
could i bother someone with #help-popcorn
I still can't get how to access the logger π
what do you want to change in it?
I dont wanna change
I just wanna log certain stuff
if that is possible
import logging
logging.WHATEVERLOG()
``` will automatically use hikari's logger
oh I see
thanks cutie
since thats set to work in the environment
yw
So now I want to make a function, when I click the button in the discord server(like the picture) and the bot will dm me , when the dm end, the bot will directly deliver all DM messages to the discord server
"when the dm end" ? elaborate
how do you define the end of the dm.
bad modal size ig?
you're adding too many items to the Modal
When I answer all the question
how are you proceeding with asking the questions
what do you mean
When i answer all the question
where does the question appear from????
bot ask me a question and I answer it
unit All the question end
em sorry about my english
π₯²
its okay i understand what you mean but when does the bot asks those questions?
when you send something or use some command?
How do I localize command responses in disnake?
can you elaborate wym by localize?
Translation
Docs do not have much information about localization, options and autocompletes are explained but not responses
you can store a list of responses and send the response on basis of its invocation
because you get the data of locale, but you can't make discord translate stuff for you.
That's not how other things are translated in disnake
how do you translate in disnake normally?
That's what I'm asking, responses aren't explained there
That I'll do
I've seen bots supporting that, they use client's language for user based things and server's community language for server based things
have you ever tried asking how they do that in their support servers?
Their framework supports that, I myself have translated some bots
and they were not python bots btw
you can't do that for responses, responses needs to be handled by your bot. Translate the text by getting their locale and translate your response according to that
!d discord.Interaction.locale
The locale of the user invoking the interaction.
And how will my bot know about user's language?
that depends on the locale ig?
Well disnake does that automatically, but I need some more if/else when I get user's langauge
PS D:\New folder\pythonProject1> pip install -U git+https://github.com/Rapptz/discord.py
Collecting git+https://github.com/Rapptz/discord.py
Cloning https://github.com/Rapptz/discord.py to c:\users\pratyush\appdata\local\temp\pip-req-build-hka3cn8a
Running command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\Pratyush\AppData\Local\Temp\pip-req-build-hka3cn8a'
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\Pratyush\AppData\Local\Temp\pip-req-build
-hka3cn8a'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
WARNING: You are using pip version 21.1.2; however, version 22.1.2 is available.
You should consider upgrading via the 'D:\New folder\pythonProject1\venv\Scripts\python.exe -m pip install --upgrade pip' command.
``` im getting this error
i recently downloaded the git CMD...(although idk how to use though)
why don't you ask in their server, they'll provide you better explanation why is that not possible
because it's dead inactive
type git in ur terminal and see if you get any errors
if you installed it and you get an error, then the git executable is not in your windows path
you need to add it manually
is there a way i can get the user's message into a reply?
heyo
im facing a positional argument error in my music bot code
class Video:
def __init__(self, requested_by, url_or_search):
with ytdl.YoutubeDL(YTDL_OPTS) as ydl:
video = self._get_info(url_or_search)
video_format = video["formats"][0]
self.stream_url = video_format["url"]
self.video_url = video["webpage_url"]
self.title = video["title"]
self.uploader = video["uploader"] if "uploader" in video else ""
self.thumbnail = video[
"thumbnail"] if "thumbnail" in video else None
self.requested_by = requested_by
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.video' raised an error: TypeError: Video.__init__() missing 1 required positional argument: 'url_or_search'
Basically if i switch requested_by with url_or_search, it happens with requested by instead
make a list of all the words you want to detect, and in ur on_message listener see if the message has any of the words from the list and then you can delete the message
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeβs robots.txt file; (b) with YouTubeβs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
i wanted to do this :c
Oh i am really sorry
Although this seems to be a python error aswell
Could you maybe look into it with a general perspective?
you need to pass both arguments in the Video class
could you elaborate on that?
!e
class Foo:
def __init__(self, a, b):
...
Foo(1)
@paper sluice :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | TypeError: Foo.__init__() missing 1 required positional argument: 'b'
thats whats happening in your case, you are only passing in one argument
like Foo(1, 2) in the example i showed
class Video:
def __init__(self, requested_by, url_or_search):
with ytdl.YoutubeDL(YTDL_OPTS) as ydl:
video = self._get_info(url_or_search)
video_format = video["formats"][0]
self.stream_url = video_format["url"]
self.video_url = video["webpage_url"]
self.title = video["title"]
self.uploader = video["uploader"] if "uploader" in video else ""
self.thumbnail = video[
"thumbnail"] if "thumbnail" in video else None
self.requested_by = requested_by
def _get_info(self, video_url):
with ytdl.YoutubeDL(YTDL_OPTS) as ydl:
info = ydl.extract_info(video_url, download=False)
video = None
if "_type" in info and info["_type"] == "playlist":
return self._get_info(
info["entries"][0]["url"])
else:
video = info
return video
def get_embed(self):
embed = discord.Embed(
title=self.title, description=self.uploader, url=self.video_url)
embed.set_footer(
text=f"Requested by {self.requested_by.name}",
icon_url=self.requested_by.avatar_url)
if self.thumbnail:
embed.set_thumbnail(url=self.thumbnail)
return embed
def setup(bot):
bot.add_cog(Video(bot))
the whole thing looks like this
ah ok ill check
anyone?
#bot-commands message
there are some links for OOP, i recommend checking them out. It would be easier for debug ur own code
basically im making a submit bot command and I want the user to add 2 things on the message and the first will be the bot id and the second the prefix. I want to do something like this:
await ctx.reply("You have submitted <@" + [the first message] + "> with a prefix " + [the second message] + " . You will be contacted for further info.")
How can I do something like that

!d discord.ext.commands.Bot.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/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
!d discord.on_interaction
discord.on_interaction(interaction)```
Called when an interaction happened.
This currently happens due to slash command invocations or components being used.
Warning
This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") instead as it provides a nicer user experience.
New in version 2.0.
!d discord.ui.Button.callback <- or
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overridden by subclasses.
not possible.
add another for loop and loop over the directories
or use pathlib.Path.glob much easier to work with
@paper sluice any good challenge for me?
tanks
make multiplayer tic tac toe
using buttons
Very hard for kid like me
hi guys
Hi
it is not? its looks hard but is actually very easy
I want to make a Telegram bot, do you know a good source?
you can just do
for directory in os.listdir('cogs'):
for file in directory:
...
u dont need 3 loops
with pathlib it would just be
extensions = list(pathlib.Path('cogs').glob('**/*.py'))
ho tanks
error
if not name.startswith('.'):
AttributeError: 'WindowsPath' object has no attribute 'startswith'
show code
extensions = list(pathlib.Path('cogs').glob('**/*.py'))
for directory in os.listdir('cogs'):
for file in directory:
extensions.append(f'{directory}.{file[:-3]}')
why do you have both
the error
for extension in extensions:
bot.load_extension(extension)
print(f'{extension} loaded!')
the error is in this part
oh do str(extension) and it contains \\ so you would have to replace it with .
and dont use both, choose between pathlib and os.listdir
It's too hard
Idk about classes so hard for me
why not just use os.listdir?
You shouldn't be making bots if you don't know about classes...
it's not a must to know classes for making buttons tho
you need to loop over again when you have nested directories, its not elegant
agreed but that's the simplest way
pretty sure oslib has a walkthrough function as well
its a recommendation, they can choose the one they are comfortable with
I am learning yet
Give me any other challenge
every project i give, you complain that its too hard without even trying, so you should probably ask someone else
Ok it's last time give me challenge pls
disnake if fork
hikari if non-forked
personal opinion, its your choice afterall.
Guys how we can play audio from file in dpy voice?
can you select a content from a message like this?
discord.Message.content(1)
select a content?
!d discord.VoiceClient.play
play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/latest/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 logged using the library logger.
Changed in version 2.0: Instead of writing to `sys.stderr`, the libraryβs logger is used.
Am I allowed to do discord web hook related queries here?
and it returns an int
ohhh
ctx.author.roles
gets all roles
for role in ctx.author.roles:
then check if role.id is the id
There is a command decorator that checks if the user has a role
!d discord.Member.roles
property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β@everyone](mailto:'%40everyone)β role.
These roles are sorted by their position in the role hierarchy.
ctx.author returns Member
Does anyone know a hosting service that can host bots using sqlite as their dbs
I know since sqlite stores data on the local drive hosting servers cannot use it?
depends on what hosting server you are using. if its one like heroku, thats not allowed
Guys is there any tts library for python?
!pip gtts
Is it possible to use in dpy?
why not?
depends on how you wanna implement it tbh
I want to make a comamnd that my bot converts text into speech and play in vc
yeah it's possibly, very much
Ok
Can I ask one thing?
Like i saw many bots have Google search comamnd and bots send link to the Google query . Is there any way that our bot displays the result in the description of the embed instead of link?
get a google search api key, then use that api
Ok
^
you can even use a library but mehh
isn't as good as the api
only returns links and urls
Ig i should use tge Wikipedia library
wut
you do know that wikipedia and google are different
?
Mostly when i use any comamnd it not works when i see the terminal it says rate limeted . But my bot don't even have much stuff
Is there any way to fix?
replit uwu
?
Should I host my bot on heroku?
do kill 1 in ther shell
Ik this i did this but it happens daily
how you gonna link the git repo to heroku...
replit issues
I'll put my bot code on GitHub
What would suggest me to do?
no hate to replit, but it's not meant for interacting with APIs that block you on the basis of IP addresses
still a lot of work
and you can't create directories from the UI
use a pc/laptop easy peasy
For what?
Pc/laptops will not provide me hosting
in heroku, you can't really edit your code. So you can edit code in pc then host it on heroku
you'll have to buy a vps or get 3 years free if you got a cc
you can get vps for free for lifetime with alts π
I should do the vps thing
rp >> vps
ew
raspberry pi
I mean repl is already a short form
why would anybody create any abbreviation for repl π
But thats computer not a sevrer
three > π
..?
π΅βπ«
Read-Eval-Print Loop
A REPL is an interactive language shell environment. It first reads one or more expressions entered by the user, evaluates it, yields the result, and prints it out to the user. It will then loop back to the read step.
To use python's REPL, execute the interpreter with no arguments. This will drop you into the interactive interpreter shell, print out some relevant information, and then prompt you with the primary prompt >>>. At this point it is waiting for your input.
Firstly you can start typing in some valid python expressions, pressing <return> to either bring you to the eval step, or prompting you with the secondary prompt ... (or no prompt at all depending on your environment), meaning your expression isn't yet terminated and it's waiting for more input. This is useful for code that requires multiple lines like loops, functions, and classes. If you reach the secondary prompt in a clause that can have an arbitrary amount of expressions, you can terminate it by pressing <return> on a blank line. In other words, for the last expression you write in the clause, <return> must be pressed twice in a row.
Alternatively, you can make use of the builtin help() function. help(thing) to get help on some thing object, or help() to start an interactive help session. This mode is extremely powerful, read the instructions when first entering the session to learn how to use it.
Lastly you can run your code with the -i flag to execute your code normally, but be dropped into the REPL once execution is finished, giving you access to all your global variables/functions in the REPL.
To exit either a help session, or normal REPL prompt, you must send an EOF signal to the prompt. In *nix systems, this is done with ctrl + D, and in windows systems it is ctrl + Z. You can also exit the normal REPL prompt with the dedicated functions exit() or quit().
Should I get a vps for 3 years free?
ehhh you can't just do that
Btw can we host bots on digital ocean?
gib money
ya just chuck it in the ocean and you will be fine
My parents dont allow me
or better if you have github student
ryuga, go and play with hikari
your jokes are way out of the line π
Hikari is not a toy ||π||
it is
get your own cc uwu
When i will earn my own then I'll buy it
you can get a lot of free stuff just by having a credit card
i won't be making discord bots if i had a real job.
same, but I don't make full bots anyways
But i will never forgot you all till i would die
i start working on them, open source them, and never finish them
owo
I have been literally editing the same code for about a month now, I don't have any ideas that suit me
try to integrate your both with redis cache
just get a job easyyyy
!pip hikari-sake π
πΏ am not 18 yet so ..
I did, but it requires everything to be in bytes, So most of the datatypes are hard to convert
and you say I'm a busy bitch π
I made like a whole algo to convert different datatypes into some sort of hash then convert them to bytes, then realized its so pointless and just use alru_cache
I still have the configs for redis, its just that none of my commands need it
fair
well, you are.
@slate swan do you know java script?
i know some basics.
this is a python server smh
same
you are scared of errors? thats a shame
I dint like js
N O
errors are easy to solve meh
Idk why me asking for challenge and dont do them
just go to school and study and waste your life for now β€οΈ
Bruh you mean that i should not study?
I never said that
You wrote to waste life in study
Which means you saying me not to study

smh, am not gonna give english lessons here nvm
If you can earn money without going to school what does it matter.
We cant earn
you can
That's not earning that's stealing.
Just kidding pls dont ban me
its just that school qualifications and college degrees are more likely to get you a job
Its a joke
Bruh never rob in life insted help others
?
I was more aiming towards own services/ company.
Oh i thought this was general lmao my badπ
yeah it's better to be heisting than robbing
Robhing and heisting both have same concept
no
oh
heisting generally needs more planning and more than two people to make it successful, anyways am not here to mislead kids
................ ................ ................ ................ ................ ................ ................ ................
no doubt why you're always high.
it's more of an issue due to less sleep π
Do you sleep?
javascript takes all the sleep away
2-3 hrs a day, yes
Like there are 168 hours a week, I probably sleep for like 8-10 hours a week lmao
like no shit
wow
no u
no, im more impressed by the fact that you know how many hours there are in a week
im not a programmer then π
smh
24x7
how hard's it Β―_(γ)_/Β―
or 20*7+4*7
13^2 - 1
File "main.py", line 55, in <module>
bot.os.environ.get('TOKEN')
AttributeError: 'Bot' object has no attribute 'os'
i have imported
from discord.ext import commands
import os
import discord
Remove bot.
alr
You are using the os module, it's not an attribute of your bot.
ig u need to cogs/comon to make ping.py run
does anyone know how to solve?
^ @slate swan
i need you to read all the files of all the folders
the bot wont read them
os.walk(top, topdown=True, onerror=None, followlinks=False)```
Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory *top* (including *top* itself), it yields a 3-tuple `(dirpath, dirnames, filenames)`.
cause they are inside 2 folders and u only made the code to read 1 folder
idk if im clear or not
for making the bot read and load the ping.py cog u need to do this :- cogs/comon
stuff inside economy :- cogs/economy
and so on
thanks
guys now i am trying to learn wait for but i cant understand
so suppose if i just want a simple response which says hello user : !xyz bot : hello user : hello [ take this response ] bot : have a good day
how will it be?
how can i send a welcome message with a non embed msg along with embed message like in the image
!d discord.ext.commands.Context.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.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
is "!" the prefix?
content=
thanks
yes
client.command()
async def xyz:
await ctx.send("hello")
def check(message):
return message.author == ctx.author
time_r = 300
try:
message = await bot.wait_for('message', check = check, timeout = time_r)
except asyncio.TimeoutError:
await ctx.send(f"{time_r} seconds passed and you didn't respond")
return
message = message.content
if message.lower() == "hello"
ctx.send("have a good day")
@indigo dagger
ok
here discord_server_name = await bot.wait_for('message', check = check, timeout = time_r) in this does the the does 'message' mean that you want a msg response from the user?
He wanted it to be like this
what is wrong in it?
and check = check
check[does this mean that what we want to check?] = check[and does this check mean the name of the function]?
@client.command
async def xyz(ctx)
while answer is True
except TimeoutError: return await ctx.send(...)
and why in the world is there a loop, and the loop will never end fyi
forgot the the (ctx) right
oops the loop shouldn't be there
well I copied it from my code and forgot to remove it
ok ziad i tried once tell me what i have to change coz my code didnt work
what is the error
def inner_check(message):
return message.author == author and message.content == "Hello"
return inner_check
@client.command()
async def trial(ctx):
await client.wait_for('message', check=check(ctx.author, inner_check(ctx)), timeout = 30)
await ctx.send('Hello')```
remove the looop
i tried this tell me what didnt work
try this
was there an error?
the code didnt work when i tried
@bot.command()
async def foo(ctx: commands.Context) -> None:
await ctx.send("Hi")
def check(message: discord.Message) -> bool:
return message.author == ctx.author and ("hello", "hi") in message.content.lower()
try:
message = await bot.wait_for("message", check=check, timeout=300)
except asyncio.TimeoutError:
return await ctx.send("rip no hello :pensive:")
await ctx.send("have a good day!")
better
too complicated for me π
dude tf




