#discord-bots
1 messages Β· Page 995 of 1
Stop.
decent
Upgrades?
bruh
How
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
@slate swan didn't u say smth about ot talks in #discord-bots channel before?
thanks hunter
Ok discord bot mode
Him and ashley both
the past is the past
π
@Mods also exists
Took*

ok..
jaguar type faster (7)
stop
3 wps
Dudes can everyone take this to an ot channel?
Jaguar stop typing and run away from here
That makes it sound like buying the game was a mistake
sure
sorry bobbi for not following your concerns
sorry BOBBI
all guys come on #ot2-never-nesterβs-nightmare
yes go there
all come
nah im waiting for jaguar
fine
I'm wondering if its gonna be shorter then before
come to ot
guys dont mind me this server is big as hell i just wanto see the intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
I've tried to simplify it as much as possible, it's a complex bit of logic.
In short:
A guild may or may not have a afk_channel (a attr of before or after
if before has a afk_channel attr or if after has a afk_channel attr then I want to add a field to my embed
so long as the above returns true once: I check if the afk_channel attr of both before and after is not None
if the above returns true then I check if the attrs are not the same, then I have my end value
if the second step returns false then I check which of the conditions caused it to be false
then depending on which of the conditions was false it changes the output value slightly
You following to this point?
My next thing is that I want to run this logic 4 times for guild.afk_channel, guild.system_channel, guild.public_updates_channel and guild.rules_channel
My idea of how to do this is create a function for it, I'm just not sure at which point of the code I should call the function (the bottom section of my previous msg where the combinations I have thought of so far)
My current condition (the code version of steps 2 - 6 above) https://paste.pythondiscord.com/cemomojosi
My current check function layout https://paste.pythondiscord.com/buxidawisi
still not a clue π
Yes.
still i have not clue why my cmds not working
show command and error if shown
i having a logic error
send code and error
As I said it's a complex bit of code
i tought the problem in my code but...
@bot.command()
async def commandname(ctx, *, somevariable):
#If you don't need a variable, then you only need (ctx)
"""Command description"""
await ctx.send('Message')
^
do you have on_message in your code?
i fixed the problem. thx, i didn't program a bot like for 2 years
what was the problemn?
use if statements and check if the return value is None/not the same
lol after reading your msg i remember why my code doesnt work (i had this problem before)
hmm ok
bobbi knows his shit 
Trying to get my time in my bots status:
@tasks.loop(minutes=1)
async def status_task():
now = date.today()
gmt_time_zone = pytz.timezone('Europe/London')
now_gmt = now.astimezone(gmt_time_zone).strftime("%I:%M %p")
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Activity(type=discord.ActivityType.watching, name=f"Time {now_gmt}"))```
Error:
```AttributeError: 'datetime.date' object has no attribute 'astimezone'```
do u want it to update every second?
minute
wouldnβt it get ratelimited with every second?
u can keep it to like 10 mins
it does for min too
perhaps you meant datetime.datetime.astimezone
iβve seen other people use every minute
hm
okay
still get an attribute error
is there an a way to msg arg with out making a cmd?
what i mean split the msg to an args
?cmd arg1 arg2
with out making a new cmd cuz i want to use it in on_msg
hm
parameters
yes
how?
.split(" ")
@bot.command()
async def test(ctx, arg1, arg2):
await ctx.reply(f"{arg1} | {arg2}")
i know about that but i wnat discord...
ctx.reply β
femboy
You don't know that?
I'm new to python
thats a thing!?!??!
i want discord to split it cuz he will take as bot.cmd
since when
split function gives a dict?
a list
i don't think you can use the api cuz your new to py
ight
Not sure, but I use it instead of ctx.send looks better to me
any ideas?
strange.
new to python u mean
ye
I'm a beginner
why would that stop him π
doesn't mean i cant use dpy
yeah wth
:( come to ot3
is it bad to query a database whenever a reaction is added?
!d discord.Message.reply @slate swan i think you can also remove that it mentions you somehow
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
idfk π
#databases i think it would fit there
it isnt until the reactions are added tok much
i see.
too*
idk someone tells me you can't use the api if your new cuz its complx and 'bot get ban'
that sound like non sense
welp
cap
good hearing that
that 'someone' is probably spreading propoganda
Not even close.
good hearing that by python server himself
When they said that the bot wil get banned they were either referring to someone using replit or doing something that was spamming the api.
Error syntax line 31 at ")"
repl.it slander
add :
Technically yes but beginners shouldn't
:
: at the end
ok
learn python π
i am going to look at the discord libery to find a way to split msg args
ok have fun lmfao
It's a known fact that they use a shared ip
IPS too
.split π
lol
that will split the space
the "keep_alive"
yes it will
what if the cmd like (a, *, b)
it will split it into a list of args
ye ik
join the last args tohether
.e
1e
!e
code
!eval <code>
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!eval print("hello")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
hello
good boi
!e
string = "arg1 arg2"
print(string.split(" "))
@strong vector :white_check_mark: Your eval job has completed with return code 0.
['arg1', 'arg2']
||inland boi||
Yo
!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = " ".join(split[:1])
print(finished)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
?cmd
bruh π
i was thinking
!e print("buggin is cute")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
buggin is cute
tysm
true
Ash do u have a discord bot
#bot-commands @slate swan
since I used json files as a db 2 years back, then tried shifting it to a database, lost interest, now it remains
I have created a bot but no hosting :(
thats how i broke my bot lmao
host yourself lol
uh that's going with me
"host yourself" sheesh
or use unlimited hosting repl.it method 
So what u do now ? In python
i normally host bots on my raspberry pi's
use aliaster.net 
i have like 15 π€£
π π
Imagine token leak
llol
i coded it wrong but you get it
y
!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = " ".join(split[2:])
print(finished)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
arg2 still arg2
idk, I just started making a bot yesterday, made 4 commands, broke them one by one, now it remains again
there we go
Whole sorce code
I've not worked on a bot for a good two months
thats why i'm gathering a development team for a big upcoming bot
discord bots are boring now
yh a little
Ye
unless you make something original
since there's a couple thousand bots for the same purpose
I like ando dev
.
!e ```py
command = "?cmd arg1 arg2 still arg2"
split = command.split(" ")
finished = [split[1], split[2]].append(" ".join(split[2:]))
print(finished)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
None
bruh π
π€¨
would u be interested in a server or a channel for discord? we could make that π€£
yt channel or a dc srv
cba rlly to make a bot rn
unless its original
im really only in the bot game atm
lol
server or a channel, but where?
wdym bro
wdym where
channel - yt or tt, server on dc
pardon?
tf is tt now, full form
tiktok
smh
man said smh
im out, nor do I have time since my exams are nearing
i jus realised i got exams too u kno
i needa revise
fr fr
how tf you making 1k a month at exam age
you can
Not hard
i used to make more from minecraft servers π€£
ive made 20 this month π
π
Yo
Same im expert
Hi
jonathan55
Yes?
nothing
Ok
u need help?
No I am looking for people to help
kinda dead chat ngl
Itβs Saturday what do you expect
How can I prevent the bot from deleting messages older than two weeks?
Lets create bot together in replit
wdym?
it does that? π
On my phone
im also not from pc
Yeah, but now how it is
jaguar is back
How do I make a command? π
I have schools on saturday :(
Many popular bots cannot delete messages that were sent more than 2 weeks ago
oh no.
I-
unlucky, mine got over day before yesterday
bot.create_command(alias="fartcommand")
that isnt a valid method?
idk
Guess what im having online classes all over may
hm
i hated online lessons π
I got an order from my server last night, so proud of my work.
Ye me too
still unlucky, I wont have to go to school for two years :doge:
split the money with me 
what server
No.
cold
What how
1 and a half year*
my issue isn't the logic (altho it could probs be better), my issue lies with which part of my code is the right place to call a_functon, if I need any checks on a_function and if there's a good way to call the function multiple times without writting the call multiple times. a_function being the function I convert this logic into
How?
Idk how, they just ordered one
what sercer
How much
And whats the order
So anyway, how to do it? #discord-bots message
Thatβs for me to know.
uh ok np
i got caught inhaling cup noodles π
Lmao
you dont
i kept the water to boil
you said you'll help π and you still havent
?
Read the docs
what is that?
ashley
xenoren
stop.
I suggest learning python first
Yep
get some help.
The popular bots probably have special things forbeing popular
thats what I'm trying to get π
wha do u wan
Im also new idk
maybe you can show the code you have right now and i could help with where you should call it
I need to output an error that the bot cannot delete messages that were sent more than two weeks ago
!d discord.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
uh why
^
Why are u decreasing ur capabilities by seeing others
It seems that you do not know how python works
Motivation
I just think it's forbidden by Discord itself
No ig
learn python then come back π»
Stop shitposting
I ask you on Discord and say that I need an error output, and you tell me about my knowledge ... "Very smart of you"
what π
Ohhh, thanks you so much
i got ponged
hehe u cant find
teach
nah, you suggested one a long back again
yeah lemme be his private tutor
uh
ashley stop. she a big pro in python
Lol
who?
P r o
u
me who doesn't know how to use for function
for function tf?
I'll just go watch some anime
for item in iterable:
i feel sick
i still dunno how to use tis
No ill help :D
I hope u get well soon
post-200 dollar loss regrets
!e ```py
list = ['1', '2', '3']
for item in list:
print(item)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
how do i use / commands?
!e
print([item for item in ['1', '2', '3']])
L
Lol
oh wait it has to be a list
L
!e bot.reply("hi")
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'bot' is not defined
o
Thats why
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['1', '2', '3']
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | HI
002 | hey
003 | hi
!e ```py
print(*item for item in ['1', '2', '3'])
@supple thorn :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(*item for item in ['1', '2', '3'])
003 | ^^^^^
004 | SyntaxError: iterable unpacking cannot be used in comprehension
Sadge
huh i have not idea what i am doing
async def function(TheSplit="('cmd', 'arg1', '*', 'arg2')"):
#split (cmd, arg1, *, arg2)
split = list(args)[:]
print(split)
cmd = args[0]
del split[0]
print(split)
return (cmd,arg1,arg2)
wabm
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | Yo
003 | YoYo
004 | YoYoYo
005 | YoYoYoYo
006 | YoYoYoYoYo
007 | YoYoYoYoYoYo
008 | YoYoYoYoYoYoYo
009 | YoYoYoYoYoYoYoYo
010 | YoYoYoYoYoYoYoYoYo
011 | YoYoYoYoYoYoYoYoYoYo
I deleted those msg se everyone can see this
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | for x in range(500)
003 | ^
004 | SyntaxError: expected ':'
Lmao
This is the last time I'm warning you guys stop going offtopic, offtopic channels exist for a reason
ok sorry
boobi we are on topic
need h
!e
for x in range(50):
print(x*"yo")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | yo
003 | yoyo
004 | yoyoyo
005 | yoyoyoyo
006 | yoyoyoyoyo
007 | yoyoyoyoyoyo
008 | yoyoyoyoyoyoyo
009 | yoyoyoyoyoyoyoyo
010 | yoyoyoyoyoyoyoyoyo
011 | yoyoyoyoyoyoyoyoyoyo
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/ikeqegapij.txt?noredirect
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
i am try to get args
and chack if TheSplit been change
Jaguar is not typing
oh lord you did not understand what i told you
no
your code does one thing i want to chack if
auhm
BrianNone not Brain = None
lol
My current condition https://paste.pythondiscord.com/cemomojosi
My current check function layout https://paste.pythondiscord.com/buxidawisi
I was thinking of calling it within embed.field.value but then realized that I don't want the field added unless either before.afk_channel or after.afk_channel exist
and I'm not sure if I should be creating the embed within the function or just returning the value of the func to embed.field.value
!e ```py
content = "?cmd arg1 arg2 and still arg2"
split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + arg2)
L
@slate swan :white_check_mark: Your eval job has completed with return code 0.
arg2 and still arg2
there we go
No
Im here
!e ```py
content = "?cmd arg1 arg2 and still arg2"
split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + [arg2])
@slate swan :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: can only concatenate list (not "str") to list
bruh
!e ```py
content = "?cmd arg1 arg2 and still arg2"
split = content.split(" ")
arg2 = " ".join(split[2:])
print(split[:2] + [arg2])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['?cmd', 'arg1', 'arg2 and still arg2']
@strong vector there we go
is that clean?
TheSplit,TheSplit,TheSplit = TheSplit.replace("("),TheSplit.replace(")"),TheSplit.split(",")
what π
its for TheSplit = "('cmd', 'arg1', '*', 'arg2')"
Thx someone understand my telent
okay listen
i'm confused just call it inside the value kwarg?
idk, im bored
wathc miru tights (an anime)
nah, I'm already watching SAO
do you like it?
Damn, finally someone who doesn't go with this hate wave, one of my favs
same
Traceback (most recent call last):
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect
await self.register_commands()
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 338, in register_commands
to_update = update_guild_commands[guild_id]
KeyError: '951383974817697793'``` how do i fix?
yeah but if the loop/conditions don't return anything (this should never happen but better to account for it) then it will error when attempting to add the field as the value will have no content. I think a variation of what you said should work tho
send code
cuz i will use it in on_msg not in bot.cmd you will know when i finsih doing my bot
ye
i don't wnat to use if
on_message blocks all commands and he doesnt know about the command listen thing
bruh
async for guild in self.fetch_guilds(limit=None):
update_guild_commands[guild.id] = []
for command in [
cmd
for cmd in self.pending_application_commands
if cmd.guild_ids is not None
]:
as_dict = command.to_dict()
for guild_id in command.guild_ids:
to_update = update_guild_commands[guild_id]
update_guild_commands[guild_id] = to_update + [as_dict]
for guild_id, guild_data in update_guild_commands.items():
try:
commands = await self.http.bulk_upsert_guild_commands(
self.user.id, guild_id, update_guild_commands[guild_id]
)```
cuz make the code ugly and hard to read
dm em your full code including token 
Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 751, in call_soon self._check_closed() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 515, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed
code
oof i want to explain what i want to do
the code worked before but when I was back in after months it did this error
what RuntimeError: Event loop is closed means
ok
wait
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
@slate swan u know how to fix anyways?
what
Yo back
someone help me pls
@slate swan
Why is my anti virus going off
idk
LMAO
so like
I should make cogs ??
Virus
@slate swan @slate swan
what i am try to do is make fuc split args.
something work like a fuc
i want to args like a fuc will do and return dict with name of the args and values of the args but what if an arg takes *args
i want to know how discord.py split a msg and make it fuc args
function
async with ctx.typing():
await asyncio.sleep(1)
await ctx.send("Please type a message")
msg = await self.bot.wait_for('message', check=check, timeout=300)
async with ctx.typing():
await asyncio.sleep(1)
await ctx.send(f"You typed {msg.content}")
how do i make the bot do the typing thing after it detects the message bc it does the typing thing even though i haven't sent a message
I uninstalled nextcord because my code didn't need it, but now it says ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
code :
import discord from discord.ext import commands
Bruh
pip show discord.py
discord.py 1.7.3
`
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>python main.py
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 12, in <module>
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>
`
i'm gonna re install discord.py
`
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender>python main.py
C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py:6: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 234, in <module>
bot.run(TOKEN)
File "C:\Users\ydzja\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\ydzja\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\ydzja\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\ydzja\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)
File "C:\Users\ydzja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000023C71B44940>
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 751, in call_soon
self._check_closed()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
`
o my
use !paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
token is invalid
Traceback (most recent call last):
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect
await self.register_commands()
File "C:\Users\mp420\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 338, in register_commands
to_update = update_guild_commands[guild_id]
KeyError: '799296335663595530'``` how do i fix this someone please help me
the key is my guild id, i checked it out multiple times. is there something else wrong there? there must be but idk what it is:(
tysm
async for guild in self.fetch_guilds(limit=None):
update_guild_commands[guild.id] = []
for command in [
cmd
for cmd in self.pending_application_commands
if cmd.guild_ids is not None
]:
as_dict = command.to_dict()
for guild_id in command.guild_ids:
to_update = update_guild_commands[guild_id]
update_guild_commands[guild_id] = to_update + [as_dict]
for guild_id, guild_data in update_guild_commands.items():
try:
commands = await self.http.bulk_upsert_guild_commands(
self.user.id, guild_id, update_guild_commands[guild_id]
)```
here async def text(ctx, arg ,*, args='test'):
how it works?:
msg = '?cmd arg1 args still args'
text(msg)
"""
text : retrun (['?cmd','arg1','args still args'], {'cmd':'?cmd','arg1','args':'args still args'})
my wifi just turn red for some reson
that why i took a long time to reply
alright
@slate swan
that what discord.py does when you call a command he split then take the args.
i want to do something like
@bot.event
async def on_message(msg):
print(text(msg.content))
if not msg.author.bot:
return
the func wouldn't be call that i will cahange that later
!d text whats text i wonder?
ooofff
@bot.command(help='random text font')
async def text(ctx, arg ,*, args='test'):
text is a cmd
where is it
i want to explain how discord.py split
I WANT TO SPLIT the msg you told me to make discord.py explain
Hey guys, how can I make a command like /post category message.
For example /post looking-for-scripter I need a scripter, and then it sends that message in the certain channel
Any documentation or sources?
yes
when you send a msg the bot split and chack if the msg start with perfix if it is he split the msg to arg i explain that in the explain
are u using slash cmds?
Not really, I would love to.
phew
They kinda complicated af.
don't now
exactly
okay let me explain why i don't use cmd
plus i split the msg content not the obj
i don't think you understood me
i want to use mutple perfix
Discord.py does indeed split the "message" into arguments, they then read the function signature along with it's annotations to know how to convert the argument
yes
that what i want to do i want to split the msg to func args
in the libery self
or... discord split
https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/view.py here's the string view responsible for parsing the content of the message, this is later passed onto the part where they use inspect.signature
async def post(cat,*,messa):
certchan = await bot.get_channel(certain_channel_id)
await certchan.send(f'{messa} - {ctx.author.mention}')```
What do you mean
do you know how do i use this low level ibery or i am going to test it.
They need the content to know what to pass to the command's callback
https://github.com/Rapptz/discord.py/blob/69b12b97c0a3f24d8dae92f855c7ab507095edc9/discord/ext/commands/core.py#L766-L787 take a look at this, you'll see what I mean?
ik < 3
I wasn't responding to you
huh kk
ERROR : u cant compare a int with a string
can i pay someone to fix this error?
It would raise an error
Unnecessary parsing or not, it doesn't matter
You need to check the content at the very least
This is the very CORE of the commands extension
LMAO
discord/ext/commands/core.py lines 780 to 781
if view.eof and self.require_var_positional:
raise MissingRequiredArgument(param)```
.bm
You were explaining a case where the user didn't provide any arguments right?
Kayya, is u Yerl?
is there an explain or can you explain?
Hey! I have a command where people can basically report something like typos or errors to the staff of the bot, were getting the id of the user and if we want to dm with their id in a command it doesnt work, but on my alt it does work! Can someone tell me why?
Aaaaaaa didn't recognize u
Ok, didn't read any of what they are trying to do, but I was responding to your statement saying discord.py doesn't split message into arguments
do i need to figure out by myself
The arguments are made by the StringView class, which is then CONVERTED by utilising inspect.signature
@slate swan where your anime pfp is?
The arguments are made by the StringView class, but are to be considered "raw"
Error:
File "C:\Users\ydzja\Desktop\Bot_Discord\Dox Defender\main.py", line 29, in get_prefix return prefixes[str(message.guild.id)] KeyError: '843234962135187456'
Code:
`def get_prefix(client, message):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
bot = commands.Bot(command_prefix = get_prefix)`
The actual conversion is done by using inspect.signature, but hence the name "conversion" it doesn't determine the arguments, just does casting
The key isn't there in the JSON
Without the StringView class you wouldn't have tokens to even convert, therefor discord.py does split to get the arguments
so much var
Can you rephrase your question?
white
I couldn't understand it
oh yeah my bad, I didn't make him rejoin, ty
Yea we seem to be talking about two different things here
im not good in list compre :<
then learn how to use them
How could i get the description of the selected option in a dropdown menu, self.values[0] gets the label but what gets the desc
ye for sure
print self.values and check dunno
Self.values is legit just a list of selected options names
idk, i hate dropdowns, so never used them
sixtyy four bits
thirty two bits
This isn't the correct channel to count bits
Is that a reference to that one thing
^
Hunter help me
..
Hm?
agreed
What request
yes 20
Actually its been like 1.5 years only since I started with Python
where do u learned python from?
I started in 2020 August or smth idk
still dont know (jk)
Eh, I started in lockdown which was in like July or smth
I still donβt know shit LMAOOO
i also started in 2020 but didnt focus a lot
lol
Was bored, me and my friend were like: Let's learn some coding. He gave up and I didn't
Heβs not a real one

the thought of the devil and the devil is here
I forgot how to navigate the dpy docs rip
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
jk
thanks
this channel is more and more off topic everyday
Agreed
For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries.
lmao
Ashley said ot 125 times in this server

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
o god π
.topic
GIVEAWAY
how do i get the list of guilds the bot is in?
!d discord.ext.commands.Bot.guilds
property guilds```
The guilds that the connected client is a member of.
ty
returns a list of Guild objects
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a βserverβ in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guildβs hash.
str(x) Returns the guildβs name.
server
then why discord use guild instead of server
NO, what Hunter said, has been said
How can I make the bot stop a command if the channel wasn't created by the bot or something like that
exit()
wow
?
use a return statement
sounds better
if not channel_created_by_bot:
return
print("uwu")```
this wont print uwu if conditional is run
no
channel_created_by_bot this is not defined or smth
@slate swan did some asking, for now there is no way to get the SelectOption object
!d discord.ui.Select.options
property options```
A list of options that can be selected in this menu.
?
<@&831776746206265384>
Uh
oof...
shit i missed that !!!!!!!!
scums
Yea just found out he can use a loop with that but too much work π
!ban 899284537312419851 troll
:incoming_envelope: :ok_hand: applied ban to @torpid zinc permanently.
uh
good evening dpy
ge
good evening
Evening hsp
good daytime for y'all
if not ctx.channel == client.user:
return```
Will this work?
anyone know what is the problem
@slate swan
why are you comparing a channel to a user
Idk
what is EXACT_TOKEN_TYPES??
@cold sonnet cuz of ash
i don't know
Im trying to make it return if the channel was created by the bot
bro?
just open the file
no way to check
then
oh
Does audit logs have it?
it would be really hard to check audit logs and store everything
....
everytime
try?
^
Oh ok
i also said no!
if ctx.author == client.user: return
Ah yes sorry
this will make it so that it won't respond if the message author is bot
it worked thanks
Some people here think Ash is a genius
rip
π³
@client.command()
async def done(ctx):
con = sqlite3.connect('main.db')
cur = con.cursor()
if ctx.author.id == 565327770083917835:
for i in cur.fetchall():
test = i[0]
test += 1
await ctx.channel.delete()```
I tried running the command but it did not work and there was no error
anyone have bot code which is used in tournament registration
oh
hi okimii
use aiosqlite, why dont you use statements?
hello sparkyπ
try:
if not channel_created_by_bot:
return
finally:
print('sike')
would raise an error
how
return isnt in a function
no except

that is understood that its supposed to be in...
I, uhh, tried to use return outside a function in a for loop once
Instead of break
?
mhm?
what do you mean
pain
well use sql statements

hi hi
Hello
is the user id, channel id, guild id always different? do they ever interfere?
ah, okay
those ids are called "snowflakes" because theyre unique as a snowflake
hmm aight, sounds nice.
they never change but
the @everyone and @here have the same as the guild
how can i let my bot check if the user said stop?
ahh
@slate swan you know any cool APIs to use for some commands
stop is a string?
you use commands don't you
yes
so if !stop is a command and run, then stop
mostly whatever you want to work with for commands, i would recommend maybe a daily top movies post or a topic you like
try mal-api for finding anime lol
well its in a bugreport command, they can report typos there etc and i want if they type stop it just stops, i already got it to stop it but it still sends the answers to the staff
Circle knows down bad is down bad
π
π³
I see, well, till yet I have pretty much every command according anime, one for searching wikipedia entries, and uhh I think the other stuff doesn't really contain anything else besides the d.py lib
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
Note
In the case of an interaction based context, this message is βsyntheticβ and does not actually exist. Therefore, the ID on it is invalid similar to ephemeral messages.
oh it's him, i didn't notice
returns a message which the message class has the content attr which returns a string
Never heard of that API, I used animec
!d discord.Message.content
The actual contents of the message.
make an anime api wrapperπ³
it can't find manga, but it can find ani news
circle down bad for knowing so much about the apiπ³
no, no, no, i'm leaving this chat, thanks for your help.
π³
can i use discord bot with threading
for?
for..
for what lol
send msg
like daily?
like in a sec
you could use Tasks but you would probably get ratelimited
Mhm 
i know you canπ
nvm π³
@slate swan DMs
it works good

π³
Yup, I like that API ngl, especially due the roleplay stuff lol
Tbh, I probably can if I would focus on it, but I will probably get lost easily and make unecessary stuff or something, maybe in the future, who knows
how i can reduce bot ping
buy a house next to a discord server
where is discord server
lmao
give me coordinates im going
then keep trying!
get better internet or live in the basement of a discord server
that's a nice tip tho.. to live in basement
Well, you know what, I don't have that much to do atm, just some debugging my bot & adding some stuff into another one, Ig then I will give it a shot
i'll give a try :"/
when i host bot in Heroku or ... gets like 15ms but in pc 300 ;-;
im confused
its fun beter than bot dev for sure!
i live in oneπ³
sql statements as, SELECT DROP FROM JOIN etc
oh
idk what yall talking about but my bots ping is fine
You already did one?
ive done many
ive done probably 5+
now im doing an api wrapper for the discord apiπ³
Ok and
Sounds like a lot of work, how long you took as average for one API wrapper?
if ctx.author.id == 565327770083917835:
for i in cur.execute('SELECT test FROM main'):
test = i[0]
test += 1
without the for loop
:'/

π that's okay actually
i get like 200 ping, and my friend gets 400
so dw about pc thing,
my ping is usually like 150 iirc
Still bitchless
PC will, at most times, get a high ping since our hom wifi networks ain't designed for hosting
cur.execute executes the command
to get the output u need to cur.fetchall or something, refer to the docs of the lib ur using
They are made for general use more
if ctx.author.id == 565327770083917835:
i = cur.execute('SELECT test FROM main')
test = i[0]
test += 1
Nah, mines fine at an average of 40-80
"most"
ok
I know many people host bots on their PCs
i was told to use sql statements
My internet is bad af
Well my 2.4G internet gives good ping but 5G gives a good speed
@slate swan 
i use my isps server as a hosting server
i would recommend learning how to use sql with python
I see
???
a day depending on endpoints
π³
bruh what i thought its hell of a work
I said I was told to use sql statements... i originally used fetchall():
Still haven't added support for Twitter's http 2 streaming service, what a loser
Twitters api is garbage
theyre a whole mess
Skill issues.
try the discors api its hugeπ
excuses
How do I get the arguments of a command?
wheres yours broπ€¨
nova, i'm looking forward if you make one twitter api :")
nice work okimii :>
for?
Hm?
novas skill is too trash for wrappers
Twitter is a lost case, won't wrap
Well, I'm not even gonna think about it, but an anime API wrapper could be doable, atleast for my lil knowledge
my wrapper is old and garbage but better than novas for sure
lmao
i believe u there for some reason lol
dont you post on Twitter like daily?????
Yeah, you b*tchhaven't followed back yet.
try one with entities and youre fine
ill follow you
when you actually post good work on github
Well, I'm lowkey already out there
loll
My work is better than your entire life
btw @olive osprey if u don't mind.. may i know what you're looking for π
its like my life they still arent finished
Is there a way to get a command from its name?
Andy moment
bro stop comparing me to andy
!d discord.ext.commands.Bot.get_command u talking about this.. or? maybe i didn't get u
get_command(name, /)```
Get a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to get aliases.
The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
Changed in version 2.0: `name` parameter is now positional-only.
youre like zeffo but zeffo is a cool guy
he sniffs socks
Nothing special, okimii just gave me the idea of making an anime API wrapper, and it sounds like something that I'm actually able to do if I focus on it
doubt
aah i see, i thought you're looking for an anime api.. well alright, good luck! π
Nahh, already got one lol
Not sure if I will do it, but thank you anyways!
:"D
its quite easy depending on the api, you could implement
- http/rest client
- cache implementation
- entities
- if the api uses ws and a gateway make a event system and handler
Well, It most likely sounds easier then it is lol
it is
a cache is not needed in rest clients boxo π
How can I edit a message that was sent before the bot restarted ? Maybe some kind of get_message
message = bot.get_message(channel, 967456535284420718)
embed = ....
await message.edit(embed=embed)
most apis ask for you to cache bro
@olive osprey
@slate swan
is it possible to loop through all the members in a server? in the code that I wrote, it only loops through the bot, not the members in the server
print(str(x.name))```
@slate swan
Alright I will give it a shot soon, atleast I will try it
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
You need to have a persistent connection to have a cache, a rest client doesn't stay connected forever so cache is cleaned the point the program ends
great
oh so do I have to write ```from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True```?
you see how i said http/rest client
depending on the api it could be one of the 2
Bor
That makes no difference bozo, say http2 client, that will only make sense!!
stop starting useless arguments nova
lets take it to dms if you want to argue with me more
Ok
you would need to make an instance of intents and then pass it to the intents kwarg in the bot class yes
Man I love this channel so much.
what does that mean ._.
Indeed. If you feel like catching up letβs head over to ot π
i would love to #ot0-psvmβs-eternal-disapproval
π³
I'm trying to make a command which you can pass multiple users to, but I'm getting error "TypeError: object of type 'Member' has no len()"
Anyone know of any free hosting services that does not limit hours per month etc? (Hosting for code)
there is fetch_message and a bot.get_message if u r using disnake
i'm using py-cord
Ah then u gotta use fetch message
how can i do that ? i'm doing all of this in on_ready so no ctx for me
I wanna slap some users myself but yeah.
How is it supposed to work
It has to be a slash command?
Ok good luck
I have work
you would need img manipulation and depending on your lib you add an argument
if you would like the users pfp then yes use pillow for img manipulation
well u need a text channel object (sorry missed yr message)
breh anyways
!d discord.TextChannel.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
Don't do it in on_ready
well pycord isn't there lol
Just use dpy π₯Ί
Bruh discord
How could I get the arguments of a command
is it a slash command?
No
!d discord.ext.commands.Context.args
The list of transformed arguments that were passed into the command. If this is accessed during the on_command_error() event then this list could be incomplete.
is there a way to do if content == table:
uh
names of args?



