#discord-bots
1 messages ยท Page 672 of 1
ok, ill go do that...
try printing submission
It looks like it hangs inside my for loop py for i in range(0, post_to_pick): submission = next(x for x in memes_submissions if not x.stickied) print(submission)
@boreal ravine i got the command to show up...now what?
any errors?
hangs? what does that mean
It wont print submission, it gets stuck inside the forloop
hmm have you tried reading a slash example in the lib your using? maybe you did somthing wrong also show me your slash variable
yeah, i copied one from the internet
@boreal ravine this is the example i was using. Now, i dont know if this matters, but where it says intents, i removed that because it was raising errors for me...do you think that effected anything?
@stark lintel do you have an error handler?
yes
no idea how to solve your issue without an error lol
show me it
@astral cobalt wait do you also have an error handler?
remove it for now
ok
or just comment the whole function out
yeah, thats what ill do
should i try again now that ive done that
yes
@boreal ravine I dont, I have it commented out so it doesent catch it so I can see the erros
ok, ill do that...
hm
Makes no scense why this isnt working
hm
async def get_meme(ctx):
print("In here")
memes_submissions = await reddit.subreddit('memes')
print("Memes submission: ", memes_submissions)
#memes_submissions = await memes_submissions.hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
print(submission)
print(submission.url)
await ctx.send(submission.url)```
It just gets stuck inside the for loop and wont set submission equal to anything
@astral cobalt can u try printing the type of meme submissions
@boreal ravine Memes submission: <class 'asyncpraw.models.reddit.subreddit.Subreddit'>
how can i make my bot send a certain msg if it sees a certain emoji on a bot's button?
hm
could it be
that this isnt authenticating correctly?
user_agent="Hello There)",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
username="USERNAME",
password="PASSWORD",
)
@stark lintel you need to enable intents from the the discord dev portal in order to use specific data you require
how. also, another question real quick...
it shows the hello command...
however, the hello slash command is commented
but it doesn't show the test command
https://discord.com/developers/applications open your bot app and go to the bot section, scroll down and u will see intents section, toggle those on
What library u using
these
Then use the, intents=discord.Intents.default()
In your code
ok
Slash commands take time to register since theyre not official dpy libraries
oh
If you have just started making your bot, I'd recommend you to use disnake
ok though, why is it still saying interaction failed?
Lemme see
like, a screenshot of what happens?
Its await ctx.send
OHHHHHH
Ye
OH MY GOD, LET ME TRY THAT
@upbeat otter You have any idea why asyncpraw isnt working for me?
IT WORKEDDDD!!!!!!!
Never worked with praw before
NOW how do i make it ephemeral message
Good
also thank you for that solution
Show the ss
i can't believe i didn't see that before
Of the current message
ok, ill send one
Do you know of any other ways to retrieve reddit posts with your bot?
@upbeat otter
Praw is the best option as of now
Ye
@upbeat otter ok, it worked, however, just for the future in case you are helping someone with a similar issue, change ephermal=True to hidden=True. this is what worked for me
THANK YOU SO MUCH THOUGH
im pretty excited rn
Ohk, thanx
NP, thank you
My pleasure
this isn't even needed
Yesh?
Explain
asyncpraw, json endpoint of reddit, a random meme api, heroku's api for memes
so it shows my two slash commands in my code, but only my one shows up, you said it will update eventually, correct?
you dont need intents for slash commands
Mhm
._.
mhm me or mhm kayle
Yeah, just dont go starting and stopping your code
oh, ok, so how long should i leave my code running to let it update
may take about an hour
damn, actually
thats why use disnake
lol, ill look into that
but in the meantime, you do think it should update on its own
Hey is there a way to get attachments from slash commands?
Should be
Huh....
should my .env contain data like this? PASSWORD=randompassword USERNAME=randomusername or like this? PASSWORD="randompassword" USERNAME="randomusername"
ok, thanks, that should be the last question i have for you for now, have a good night
and you too @boreal ravine thanks for the help earlier
Can we?
But Its 9 am
Try doing, ctx.message.attachments
second one
No it didn't work
Idk then, ask kayle
Hmm ok
@upbeat otter Why do you check everything you write out in discord with the line through it?
Why not
thanks and now Lemme go have by breakfast ๐
Bye..m
does it mean something?
maybe
your not doing it right
pretty easy lol
async def meme(self, ctx, subred="memes"): # default subreddit is memes, later in the command you can select one of your choice (example: !meme python --> chooses r/python reddit post)
msg = await ctx.send('Loading ... ')
reddit = asyncpraw.Reddit(client_id='CLIENT_ID',
client_secret='CLIENT_SECRET',
username='USERNAME',
password='PASSWORD',
user_agent='useragent')
subreddit = await reddit.subreddit(subred)
all_subs = []
top = subreddit.top(limit=250) # bot will choose between the top 250 memes
async for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
embed = Embed(title=f'__{name}__', colour=discord.Colour.random(), timestamp=ctx.message.created_at, url=url)
embed.set_image(url=url)
embed.set_author(name=ctx.message.author, icon_url=ctx.author.avatar_url)
embed.set_footer(text='Here is your meme!')
await ctx.send(embed=embed)
await msg.edit(content=f'<https://reddit.com/r/{subreddit}/> :white_check_mark:') # < and > remove the embed link
return```
@slate swan Then im just stupid lol, i have 0 clue why it wont work, it doesent even throw an error
it just simply doesent work
why is the reddit var in the func?
it should be a global var idk why you put that their
give me one sec
thought that might have been why
async def get_meme(ctx):
print("In here")
memes_submissions = await reddit.subreddit('memes')
print("Memes submission: ", memes_submissions)
#memes_submissions = await memes_submissions.hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
print(submission)
print(submission.url)
await ctx.send(submission.url)
``` this is what mine actually looks like
ik this is spoonfeeding but im bored:
@bot.command()
@commands.cooldown(1,120,commands.BucketType.user)
async def setup(ctx):
print("setup command has been executed")
subreddit = await reddit.subreddit("setups")
all_subs = []
top = subreddit.top(limit = 200)
async for submission in top:
if not submission.is_self:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
em = disnake.Embed(title = name)
if "jpg" not in url or "png" not in url:
pass
if "jpg" in url or "png" in url:
em.set_image(url = url)
await ctx.send(embed = em)
its old btw lol
@upbeat otter ?
Yeah?
what was that for ๐ค
Wdym indent? @upbeat otter
indents are right lol
The indents in the code looked weird
discord makes it look like that
-_-
ok bye now
Bye
And people say they code on discord
eh me too im sure eevee will help with his problem
lmao
thats really bad.
My God
im very sure
ik its old code i stole lol
did you steal that code from somewhere?
didnt bother to change it
yes thats so
I never used praw before so meh
where exactly?
pretty easy but youll have to use asyncpraw
yt vid lol
works so i didnt even bother
i wont even bother helping
I thought its just the asynchronous version of praw ngl
i dont need helping
it is lol
it is
you indeed need help
hence "async"
just the async instance of praw
Somone online said its not worth using the async version
asynchronous synchronised async function
your using dpy which is async so you will
well
next time block their face with a keyboard everytime they breathe
ok bye now
The answer is simple, that someone was dumber than me
your so good with ideas?

yeah i just drank a cup of coffee and iโm getting ready for some work . its 6:43 am
so iโm booting up
Your apex legends await, play now
ikr
thats correct
hold up how you know you stalker๐ถ
okay cya
6:43? Where do you live @slate swan
bye๐ถ
ur status
Lol, good luck
ik but he stalking me๐ถ
some part in the middle east
not really. then whats the point of it
Ehh, I am not a "he"
discord add it so idk๐งโโ๏ธ
!ot
Off-topic channels
There are three off-topic channels:
โข #ot2-never-nesterโs-nightmare
โข #ot1-perplexing-regexing
โข #ot0-psvmโs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
my bad
Lol
Me too bye

@slate swan The setup function does the same thing as my last it just freezes inside the forloop
how does something freeze inside a for loop? that doesnt make sense unless the values inside the iterable your trying to unpack is really big
Doesent make sense to me either, it just wont iterate
can someone send me a example uptime code?
Hmmm
I have a botvar, which is set to a timestamp and then I use discord's timestamp markdown feature ๐
code where? im not that smart
i completely forgot how to code in python lol
i quit using python for so long
everybody wants the code, no one wants the explanation
Just their things should work
I dont give free code, but heres an example```py
from datetime import datetime as dt
bot = ...
bot.uptime = dt.utcnow().timestamp()
async def timestamp(ctx):
...
Time to bribe?
@lost wolf do u know about the discord's unix timestamp feature?
no
time.time also works
o
does time have a timestamp attr?
@client.command(pass_context=True)
async def uptime(ctx):
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
embed = discord.Embed(colour=0xc8dc6c)
embed.add_field(name="Uptime", value=text)
embed.set_footer(text="<bot name>")
try:
await ctx.send(embed=embed)
except discord.HTTPException:
await ctx.send("Current uptime: " + text)
shouldnt that work?
what should i define start_time as?
try it and see
a datetime.datetime object probably
oh your using time
Is that copied code? I see pass_context and thats useless now
no i copied code from my old bot lol
time.time() โ float```
Return the time in seconds since the [epoch](https://docs.python.org/3/library/time.html#epoch) as a floating point number. The specific date of the epoch and the handling of [leap seconds](https://en.wikipedia.org/wiki/Leap_second) is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. This is commonly referred to as [Unix time](https://en.wikipedia.org/wiki/Unix_time). To find out what the epoch is on a given platform, look at `gmtime(0)`.
Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.
@client.command()
async def uptime(ctx):
start_time = time.time()
current_time = time.time()
difference = int(round(current_time - start_time))
text = str(datetime.timedelta(seconds=difference))
embed = discord.Embed(colour=0xc8dc6c)
embed.add_field(name="Uptime", value=text)
embed.set_footer(text="NeoBot")
try:
await ctx.send(embed=embed)
except discord.HTTPException:
await ctx.send("Current uptime: " + text)
that?
bot = ...
start_time = ...
๐
botvars exist
yus
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
@upbeat otter when i implemented to slash command, it broke all of my other commands that have buttons, do you know why that may be, and how to fix it?
i can ss the error it gives
big old glob of red
lmfao
i fixed it
but i have no clue how
i just typed the comment "#poop"
and it magically fixed my code
if this doesn't sum up python, i dont know what does ๐คฃ
`
discord.ext.commands.errors.ExtensionNotFound: Extension 'info' could not be loaded.
import discord
from discord.ext import commands
class info(commands.cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
@commands.command()
async def hello(self, ctx, *, member: discord.Member = None):
member = member or ctx.author
if self._last_member is None or self._last_member.id != member.id:
await ctx.send(f'Hello {member.name}~')
else:
await ctx.send(f'Hello {member.name}... This feels familiar.')
self._last_member = member
bot.add_cog(info(bot))
?
nvm i fixed it
now i got another error
TypeError: module() takes at most 2 arguments (3 given)
class info(commands.cog):
thats the line its finding the error on
@boreal ravine can you help pls
someone help
@marble cradle
@cinder horizon do you know?
do you know?
@lost wolf innitcommands.Cog?
huh
i mean cant help wen m not shore myself...so nope sorry idk
its commands.Cog
AttributeError: module 'discord.ext.commands.bot' has no attribute 'add_cog'
def setup(bot):
bot.add_cog(info(bot))
discord.ext.commands.errors.ExtensionNotFound: Extension 'info' could not be loaded.
why is it having so much trouble loading cogs
discord.ext.commands.errors.ExtensionNotFound: Extension 'info' could not be loaded.
@lost wolf is info the class name?
class info(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
Okay...
import discord
from discord.ext import commands
class info(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
@commands.command()
async def hello(self, ctx, *, member: discord.Member = None):
member = member or ctx.author
if self._last_member is None or self._last_member.id != member.id:
await ctx.send(f'Hello {member.name}~')
else:
await ctx.send(f'Hello {member.name}... This feels familiar.')
self._last_member = member
def setup(bot):
bot.add_cog(info(bot))
``` @lost wolf run exactly this and say waz its showing
Yea
self._last_member = Nonewt exactly is this for i dint get tht...
Traceback (most recent call last):
File "/home/allans/Bot/main.py", line 31, in <module>
client.load_extension("info")
File "/usr/local/lib/python3.7/dist-packages/discord/ext/commands/bot.py", line 676, in load_extension
raise errors.ExtensionNotFound(name)
discord.ext.commands.errors.ExtensionNotFound: Extension 'info' could not be loaded.
...
?
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
<client/bot>.load_extension(f'cogs.{filename[:-3]}')
print(f'Loaded {filename[:-3]}')
```add this in ur `on_ready` and try
show full error
and delete client.load_extension?
that worked thanks
@commands.command(hidden=True)
async def translate(self, ctx, *, message: commands.clean_content = None):
loop = self.bot.loop
ret = await loop.run_in_executor(None, self.trans.translate, message)
embed = discord.Embed(title='Translated', colour=0x4284F3)
src = googletrans.LANGUAGES.get(ret.src, '(auto-detected)').title()
dest = googletrans.LANGUAGES.get(ret.dest, 'Unknown').title()
embed.add_field(name=f'From {src}', value=ret.origin, inline=False)
embed.add_field(name=f'To {dest}', value=ret.text, inline=False)
await ctx.send(embed=embed)
```help??```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/cogs/test.py", line 67, in translate
ret = await loop.run_in_executor(None, self.trans.translate, message)
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/googletrans/client.py", line 182, in translate
data = self._translate(text, dest, src, kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/googletrans/client.py", line 78, in _translate
token = self.token_acquirer.do(text)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/googletrans/gtoken.py", line 194, in do
self._update()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/googletrans/gtoken.py", line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
how tf is that even possible
@commands.command()
async def botinfo(self, ctx):
embed = discord.Embed(title="BotInfo")
embed.add_field(name="Server Count", value=str(len(bot.guilds)))
await ctx.send(embed=embed)
@boreal ravine
ok removed None (ret = await loop.run_in_executor(None, self.trans.translate, message)) but
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "/home/runner/cogs/events.py", line 191, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/Trust-Worthy-Runtime-Bot-2/cogs/test.py", line 67, in translate
ret = await loop.run_in_executor( self.trans.translate, message)
File "/usr/lib/python3.8/asyncio/base_events.py", line 783, in run_in_executor
executor.submit(func, *args), loop=self)
AttributeError: 'function' object has no attribute 'submit'
you dont have guild intents...
!d discord.Intents.guilds
Whether guild related events are enabled.
This corresponds to the following events...
isnt that enabled by default?
it is , but in case they changed it..
o
how do i
Enabled by default as in no intents passed or using Intents.default()?
set the value "discord.Intents.all" to an intents kwarg in your bot variable
no idea
Well, if no intents are passed to the constructor your client identifies to the gateway with an intents value of 0. If you identify with Intents.default it will identify with an intents value of 32509, meaning all intents except for privileged ones
How to make a command both slash and a user command?
in pycord
Intents = discord.Intents.all() didnt work
I got rate limit
do u have intents=Intents in your bot constructor
can anyone tell whats the error in this
@client.event
async def on_reaction_add(ctx, user, reaction):
channel = reaction.message.channel
if reaction.emoji == '๐':
await ctx.message.send('hoii')
Using replit?
peace
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesnโt require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโs required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
It takes only reaction and user, nothing else
but if i want to send msg to a channel too then?
you defined channel did u not? just do channel.send then
channel = reaction.message.channel
like this u mean?
the error is
message.channel.send or channel.send
Yea
oh
ty i fixed it
not me
None. U have a higher IQ than me at least
yea
sure
Beating you as in physically?
sussy baka
Lmao
how to prevent this error from showing and how long does this cooldown last?
waht
๐ถ
You got ratelimited lol
Regenerate your token
WHy ?
show ping in ember msg
Ping what?
Ah the latency
example 26 ms
can u write new code ?
Add f
So it will be a f str
oh that is works tnx
Yw
have is error
. how to fix that ?
Use only a f str?
yes
just adding f
Your using format and f str a f str does the same thing as format
what is new code
pls type that
im confused
Just delete .format
No need
sad, yeah
btw how to connect discord.py to some game renderer? like uh... unity smth
Unique question and why exactly would you do that?
lol i wanna make online game
With dpy?
like that jelle vernande smth
No idea
๐โโ๏ธ
๐ด๏ธ
if i not wrong replit hav it's own hosting web, should i use it or friggin change to heroku
Dont host your bot at that point
waht why
sadge
Heroku is the better option but not the best option
here's 2.01 pm here-
Good night
Ast lol
what is the best
Gn
breh pay ;-;
this or an actual paid host
Now i will leave infernum have fun ๐ถ
Yes gn
ah i see, ok
Gn
:vvvv ok
๐ถ
my stats command not working and dont have error ๐
Hello, my command gives me an error that says: ```
Ignoring exception in command user:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 467, in _actual_conversion
return converter(argument)
TypeError: 'types.UnionType' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1329, in invoke
await self.prepare(ctx)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 552, in transform
return await self.do_conversion(ctx, converter, argument, param)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 505, in do_conversion
return await self._actual_conversion(ctx, converter, argument, param)
File "/usr/lib/python3.10/site-packages/discord/ext/commands/core.py", line 476, in _actual_conversion
raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "UnionType" failed for parameter "user".```
Code:
@_user.command(
name="avatar",
description=_("castle.bot.commands:utility:user:avatar.description"),
)
async def avatar(self, ctx: commands.Context, user: User | int = None):
user = self.bot.get_user(
user.id
if isinstance(user, User)
else user
)
user.avatar_url_as(format="gif" if user.is_avatar_animated() else "png")
async with ClientSession() as session:
async with session.get(avatar) as response:
image = await response.read()
with BytesIO(image) as file:
await ctx.send(
"{0} {1}".format(
_("castle.bot.strings:utility:user:avatar.user_avatar"),
user
),
file=discord.File(file)
)
``` `_user` is `commands.Group`.
Because you're not sending your embed to a channel.
Add await ctx.send(embed=embed) after your embed declaration.
oh no im very wtupid
stupid
tnx
@rare roost Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!
maybe the "f" is not neccesarry? just response
title=response, description="" (if u want blank)
try remove it and screenshot the error code
what
File "C:\Users\ADMIN\PycharmProjects\Fluxo\main.py", line 33, in on_ready
await channel.send(f"Fluxo is now online | Current Ping:"+ {bot.latency * 1000})
TypeError: can only concatenate str (not "set") to str
hmm, try to change @commands.cooldown from bottom of @client.command() to the top of that
oh nvm, not like that, lemme see again...
where did game.reset() come from
i have a file named "game" and i import function reset from it xd
okay
yes it is
oh i use discord.py and pycord too XD
okay
"C:\Users\ADMIN\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\ADMIN\PycharmProjects\Fluxo\main.py", line 33, in on_ready
await channel.send(f"Fluxo is now online | Current Ping:", {bot.latency * 1000})
TypeError: send() takes from 1 to 2 positional arguments but 3 were given
please don't judge me i dont kno much about f strings
how can i embed a servers icon?

as a thumbnail
embed.set_footer(url=ctx.guild.icon_url)
okokokkkok
U should probably learn them, itโs like a very basic concept
hi
You don't need self when it's not in a cog.
hello
Basically, when handler gives you a commands.Context object, your command receives it as self and not ctx because your command isn't in a cog.
breh why strikethrough
do NOT shit on the on_ready event, changing presence in on_ready makes your bot even more vulnerable to losing connection
Exactly
why not
Do not put any API calls in an on_ready event
It's not necessary because you're doing same thing while just giving your variable as keyword argument, giving f-string isn't actually needed if you're passing only one variable.
you're missing the closing string
how to fix it ?
a string is not closed
Wrap your keyword arguments for better readability.
No, you posted a wrong answer, so we fixed it
Never make API calls in an on_ready event
It's a dispatch event that can get called multiple times and if you make API calls the moment, your bot connects to discord Gateway, there is a high chance that Gateway will completely disconnect your bot
Use the bot constructor to set the status, when your bot gets online
bot = commands.Bot(..., activity=....)
discord.py to unity?? Discord.py is an API wrapper written in python for discord API and unity is a game engine, you can't connect it and even if you could, it would be very complicated
If you want to code it on unity I guess you can learn C# and make discord bots from there
iirc there is a module for it
hi
!ot
Hmm
everyone how i can find server member with guild , i use {ctx.guild.owner.id} but bot say None !
Show code
what's the ctx for mentoining a certain user or could i just do @slate swan
Member and User object has an attribute called mention
that returns the string to be used to mention them
soo.. mention(521325126722125874)?
no?
what is it then
!d discord.Member.mention
property mention: str```
Returns a string that allows you to mention the member.
im not going to explain basic use of classes here

ImportError: DLL load failed while importing _brotli: Specified module not found.
how to fix
Have you tried pip install?
screenshot
!ot
Please
lol
haha just kidding
I canโt understand that language , but have you tried pip install?
what does the brotli package do?
Did it work?
PS C:\Users\Laxuzer> pip install _brotli
ERROR: Invalid requirement: '_brotli'
Have you tried it in the terminal?
!pypi brotlipy
!pypi Brotli
And also whatโs _brotli
Belirtilen modรผl bulunamadฤฑ. mean Specified module not found.
Does it have an underscore behind it?
Everybody ignores my answer
Which answer
yes
@velvet tinsel
The module doesnโt exist
,-,
With an underscore behind it
they just simply ignored it
PS C:\Users\Laxuzer> pip install brotli
Requirement already satisfied: brotli in c:\users\laxuzer\appdata\local\programs\python\python310\lib\site-packages (1.0.9)
already install
import brotli
its work!! thankss โค๏ธ
@upbeat otterthanks
They gave the answer
I'll just live in the shadows, its okay
welcome
No thatโs me
does that thing even has to do anything with discord bots
!ot
โฆ.no ig
lol
yep?
How do you make a discord bot
from discord import discord_bot
discord_bot.start()
Omg tysm
welcome
That answer changed my life
Ok
can we set multiple owner ids in commands.bot?
wdym
like in this only my id is set
!d discord.ext.commands.Bot.owner_id
The user ID that owns the bot. If this is not set and is then queried via is_owner() then it is fetched automatically using application_info().
i want to add one more person
try using a list
I donโt think and would work either
only one person should own the bot
exactly
didnt work
oh
how can 2 people own 1 bot
Teams there is a discord teams thing
๐
ah yes
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
Yes
thats where you create the app
oh
i am trying to make a command which adds the argument in a txt file but the file isnt getting updated
@bot.command()
async def ban(ctx, *, argument):
with open('curse.txt', 'w') as f:
f.writelines(argument)
await ctx.send(f'yoyo{argument}')
```help pls
btw, do you wanna use the @is_owner at many places?
how can i write an text to a file
yea kinda
do you want to overwrite?
this is not the right channel, #โ๏ฝhow-to-get-help
hmm......I see
sorry
no just write like
argument1
argument2
close it
you can use the append mode and use the write method
anyways, Myxi will help, igtg
also that isn't async, it will block the entire script until the IO is complete
Myxi activate god mode
bro when i made it ids and then made it list and it worked
Yay
everybody isnt a bro, niceeeeeeee
What if theyโre a girl?
๐
Right bro? ๐๐๏ธ
๐ฅ hi
Bye
can anyone run me through something with sql real quick? ive got my primary command working fine with writing 3 arguments on the database file using sqlite3, now i have a secondary command in which im trying to make my bot read those arguments, using databases with sqlite3 how can i read the file?
Goodbye
This is #discord-bots
its for a bot..
Alright then
i mean, the arguments are ctx.guild.id, ctx.channel.id, rold.id
i need to know how i can make my secondary command read those columns in the database
there is a specific channel for it, #databases
when specifying an emoji arg, it has to be str right?
This channel is for anything that is exclusive to a discord bot, databases aren't
@bot.event
async def on_message(message):
if message.author.id == bot.user.id:
return
msg_content = message.content.lower()
with open('curse.txt', 'r') as f:
f.readlines()
if any(word in msg_content for word in f):
await message.delete()
await message.channel.send(f'bhasha bro {message.author.mention}')```
erro:
ValueError: I/O operation on closed file.
is the indentation wrong of with open?
how to send message to user with discum?
discum?
!pypi discum
how do i get the bot to reply to the mentioned user
Against ToS
!command
<bot's reply>
Which message? I am confused ngl
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
!d discord.MessageReference.resolved
The message that this reference resolved to. If this is None then the original message was not fetched either due to the Discord API not attempting to resolve it or it not being available at the time of creation. If the message was resolved at a prior point but has since been deleted then this will be of type DeletedReferencedMessage.
Currently, this is mainly the replied to message when a user replies to a message.
New in version 1.6.
What's that
to configure opus to make the bot speak in vc
how do i use it tho
ctx.message.resolved.reply
got it thanks
Every time after some time I restart my bot I have to install discord.ui again and then I get this error Someone who can help me?
Are you making sure to install 2.x
what do you mean? i always install: pip install -U git+https://github.com/Rapptz/discord.py
Should work then
how to use on_message with ctx
idk whats wrong im brand new to this
the 4th line capital C worked on the video and thats not the syntax error
The 2nd client.event shouldnโt be indented
Itโs a separate function
And the client.run(โtokenโ) is seperate as well
looks like they're following freecodecamp's tutorial
don't follow that guy, his code is outdated and bad
ive only just started doing gcse coding
oh
i wanted to push myself so yh, thanks for the advice, ill find a different tutorial
best way to learn discord bot development is by learning python's intermediate stuff and then have a look at the examples and docs
yeah ive heard github is really good, thanks!
other ways will teach you how to make a specific thing working and you will be stuck doing absolute basic stuff
But copy pasting code not knowing what itโs doing isnโt much of a push and wonโt help u that much
try to be a programmer not discord bot developer
like wjat
this
alias
ask @slate swan
yeah say code
I'm going to sleep, bye
use the aliases kwarg, also, they need to be a string
pls send code
no bro wtf
smh
that's literally basic python, you're on your own here
code
i dont speak with you๐ก
fax ๐
hey noob hi
"say" the code @slate swan
wth
No spoonfeeding
!d discord.ext.commands.command
@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") using utf-8 encoding.
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
even gave you the docs smh
one of the attributes the .command can take
what is true code
that is ||code||
๐
makes no sense at all
ngl i'm confused on how subclassing views work , i've understand buttons but views
. mind linking me some place that shows examples and stuff ?
How to make a Discord Bot reply to a specific message rather than every message including a word?
Subclassing allows you to inherit the attributes and methods of the class that you are subclassing and you create new attribute/methods or override the methods, same is with views, you subclass view and add your button as items and then override the methods of the view to your choice
oh
let me see
So let's say you created a select menu which lets you select some stuff, you can subclass View and add your select options as items and then override the methods like on_timeout interaction_check to do your bidding
hello, I am getting an error in the backup software, everything is being copied but the channel permissions are not being copied can anyone help?
You would need to use regex for that
yeah i got it , i'll come back when i try it
disnake
help pls
what are u trying to do? what is the error?
I backup the server but the channel permissions are not backed up
cmd crashes and closes
failed to copy channel permissions
can I use a select menu and a wait_for method together?
You can
But why
confirmed?
but like will it work?
You can always try it yourself
can you get guild by name?
bot.command not working if there is @bot.event writted
for example in the picture, how to make bot.command & bot.event work together?
my prefix blank I didn't fill it in.
if any(word in message.lower() for word in guilds[str(message.guild.id)]["words"]):
await message.channel.purge(limit=1)``` KeyError: Guild ID
You need to call process_commands in your event
This is event is overriding the default message event
and I would recommend you to use a listener
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").
Example...
help?
Your complete traceback
?
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "main.py", line 42, in on_message
if any(word in message.lower() for word in guilds[str(message.guild.id)]["words"]):
KeyError: '894122745271566356'```
@untold token
"894122745271566356" key does not exist in the file
its simply written there
{
"894122745271566356": {
"words": []
}
}```
make sure you're opening the right file
so what should I do?
your code please
async def update_guild(message):
with open("guilds.json","r") as f:
guilds = json.load(f)
if not str(message.guild.id) in guilds:
guilds[str(message.guild.id)] = {}
guilds[str(message.guild.id)]["words"] = []
with open("guilds.json","w") as f:
json.dump(guilds,f,indent=2)
@client.event
async def on_message(message):
with open("guilds.json","r") as f:
guilds = json.load(f)
await update_guild(message)
if any(word in message.lower() for word in guilds[str(message.guild.id)]["words"]):
await message.channel.purge(limit=1)```
your update_guild and the if statement should be outside the with open()
<indentation>
Any good library out there for util commands on my bot? I have a google crawler and a wiki command atm
what do you wanna do, thats the point
He or she said it lol
util commands include some kind of command type
it doesn't really matter, do u guys know any fun or good library for bot commands
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "main.py", line 42, in on_message
if any(word in message.lower() for word in guilds[str(message.guild.id)]["words"]):
File "main.py", line 42, in <genexpr>
if any(word in message.lower() for word in guilds[str(message.guild.id)]["words"]):
AttributeError: 'Message' object has no attribute 'lower'```
I thought you talking about something else lol
message.content.lower()
,-,
Not really what I meant
then
A library such as google crawler or wiki that lets the user do fun stuff, it could be anything
hmmm.....I see
@slate swan when you call the on_ready event you can do this
import sys #at the top of course
@client.event
async def on_ready():
sys.exit()
print("have fun")
lol nice one
wait what the
torture 
why not do it in a esoteric way xD
sure
async def on_ready():
del <client/bot>
thank me later
@slate swan You can use the google module to do google searches
Yeah I thinked abt that one too
!pypi google
try
@bot.listen()
in the event
Oldest trick in the book
indeed
is there a way to have a bot restart itself?
is there something like "button_click.author" ?
im trying to do a ticket system that when you click a button you would be added to a text channel but by name not by role
hello so im trying to make my bot delete a role from the server i use guild.roles and specifie what one to delete yet it doesnt delete it and i cant seem to see why not, it has admin it can delete other things just not roles, the role of the bot is higher than what it is trying to delete
!d discord.Client.close || py await bot.close() #closes the bot os.system('python main.py') #runs the bot file again where os is the built-in function os
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
!d discord.Role.delete || any errors?
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the role.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.
ty
what code do you have?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50028): Invalid Role
this is an error but it doesnt make any sense
since if i print the list of guild.roles it shows correct
then i use await role.delete()
you have gotten the role incorrectly
how did you get your role instance?
did you do guild.roles? because that returns a list
do hosting services allow doing this
what role do you want to delete? you can't delete all of them
for role in guild.roles:
they do
thank youu
cause i have to loop all the roles
can someone please answer me ?
to see what one has the right name
most of them give access to terminal
which lib?
its no different to restarting it manually
discord_components
its, variable.user
in theory since im looping through them it should work
if amount.lower() == "all":
amount = int(guilds[str(ctx.guild.id)]["warns"][str(member.id)])```
```json
{
"894122745271566356": {
"words": [],
"warns": {
"770210759359070209": 4
}
}
}```Failed to convert from string to int
im not trying to delete using the whole list
@everyone role is included, and you cant delete that
amount = int(amount)
@everyone is the first index in guild.roles, so thats why its erroring
i added a try accept
so it would pass that still doesnt delete other
if amount.lower() == "all":
first of all, what you're trying to do and the code you currently have
all = the amount of warns
and?
Converting to "int" failed for parameter "amount".```
smh, the codeblock
try print(role) to see what the role is, and why it is erroring
amount: Union[int, str]
i got this error
code?
The greatest ML God is here
machine learning
martin luther
O

yes sorry that ^^
variable.user: discord.PermissionOverwrite(read_messages=True)
the codeblock
not just a single line
got it working now
i just havving to specifie directly from the list
and I dont think colons are a thing like that
Yes they ain't
@bot.command()
@commands.guild_only()
@commands.has_guild_permissions(manage_channels=True)
@commands.bot_has_guild_permissions(manage_channels=True)
@commands.has_role("ใ๐ปใ Bot Developer")
async def skin(ctx):
embed = discord.Embed(
title = "Vytvorenie skinu",
description = "Toto je popisok.",
colour = discord.Colour(0x80ff80)
)
embed.set_footer(text="bot made by samuelll hehe")
embed.add_field(name="Meno poฤพa", value="Nieฤo 1", inline=False)
await ctx.send(embed=embed)
await ctx.send(type=InteractionType.ChannelMessageWithSource, content="Len testujem buttny", components=[Button(style=3, label="Default Button", custom_id="button")])
res = await bot.wait_for("button_click")
role = discord.utils.get(ctx.author.guild.roles, name="cekam na skin voe")
await ctx.author.add_roles(role)
await res.respond(content="Otvoril si ticket !" )
overwrites = {
ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False),
ctx.guild.me: discord.PermissionOverwrite(read_messages=True),
role: discord.PermissionOverwrite(read_messages=True),
variable.user: discord.PermissionOverwrite(read_messages=True)
}
channel = await ctx.guild.create_text_channel(name="objednavka - skin", overwrites=overwrites, category=bot.get_channel(902994748556574740))
these checks gonna make me act up
your code is looking christmasy with all these decorations ;)
i am trying to add emoji in ad text but its not replying with anything
@bot.command()
async def test(ctx):
message = await ctx.send('test')
emoji = '<rick_roll:899653182081351680:>'
await message.add_reaction(emoji)```
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type member_descriptor is not JSON serializable
get it? decorators...
good one
If you want to get the count of 'warns', then you should use len() as it returns a list.
last line
I really dont.....know
{
"894122745271566356": {
"words": [],
"warns": {
"770210759359070209": 4 // length?
}
}
}```
help pls
!e
data = {
"subdata": {
"a": "b",
"c": "d"
}
}
subdata_count = len(data["subdata"])
print(subdata_count)
i thought so ๐ฅฒ
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
2
what's the error @jovial osprey
now its this discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'variable' is not defined
I gave the name variable as an example so that you could replace it with the variable in your own code lol
len(guilds[str(ctx.guild.id)]["warns"][str(member.id)]) will return the count of warns.
when i replaced it
huhhh
does exactly
nothing
Show me your code.
@jovial osprey it will be- res.user
when i replaced variable with discord.user (found it on discord_components) i got this TypeError: Object of type member_descriptor is not JSON serializable
what to do if on_message ate all comands?
Imagine studying
Change the deco to bot.listen()
res.user
still other things arent working
oh it works now, thanks so much
sorry for earlier
In on_message at the bottom put await bot.process_commands()
!d discord.ext.commands.Bot.process_commands
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the messageโs author is a bot and doesnโt call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
notbot MUST be a commands.Bot/discord.Client object though
~~
weirdest variable names i've seen~~
thats the point
discord.Client cant process_commands ๐คฆ
๐คฆ
๐คฆโโ๏ธ
anyways can I ask for api help here I keep getting 401 code when trying to run my bot
Sure
you asked to asked the question while asking the question
I just get this ```py
{'message': '401: Unauthorized', 'code': 0}
I don't know why it's unauthorized
kayle doesnt know what naming conventions are so everytime kayle is here i am esoteric and help with the worst information possible
cry about it
she did on_member_join(ctx)
sure ๐
that's sad to know
Cz u didn't specify the headers in the request
I did
im petty
I read that as pretty xD
still not working
bot might not be bot idk
im both ๐
Also u need the argument
im cis male
@bot.listen()
async def on_message(message):
if message.author.id == bot.user.id:
return
msg_content = message.content.lower()
with open('curse.txt', 'r') as f:
hm = f.readlines()
if any(word in msg_content for word in hm):
await message.delete()
await message.channel.send(f'Watch Your Language {message.author.mention}')
await bot.process_commands()
i even changed listen to event but still
i got muted for 2 days because of this
Bot <token>
U specified a space?
yes
no, it was because of your language
bot.process_commands(message) also
!d aiohttp.ClientSession has a headers kwarg
class aiohttp.ClientSession(base_url=None, *, connector=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=json.dumps, ...)```
The class for creating client sessions and making requests.
Try using that
okay
niceee
im still getting unauthorized
Still?
actually?
yeh
code looks like this ```py
async with ClientSession(headers=headers) as session:
async with session.post(
f"https://discord.com/api/v9/channels/{voice_channel}/invites",
json=data,
) as raw:
๐ค how do check if a member has a role with if statement
Can u remove half the token and then show the code with the headers?
why tho....
if guild.get_role() in member.roles
๐ค one second
help?? this works fine but when it creates the role it wont send setup completed ```py
@commands.command()
async def setmute(self, ctx):
role = discord.utils.get(ctx.guild.roles, name="Muted")
if role:
await ctx.error(f"This guild already has the {role.mention} role.")
return
try:
new_role = await ctx.guild.create_role(name="Muted")
for channel in ctx.guild.channels:
await channel.set_permissions(new_role, send_messages=False)
await ctx.send(f"Setup completed, I have create the {new_role.mention} role.")
return
except:
pass
crab game
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/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.
oh
does ctx.member.roles work too
ctx.author.roles
aww man you can only get the user of the command?
headers = {
"Authorization": f"Bot MDM2ODY2MjQ1MzQzNjgxOQ",
"Content-Type": "application/json",
}
:c
U can ask the person for a member and use that
no
i didnt even call him an idiot, i just said dont be an idiot
is it possible to make a text channel with name of the one who requested ? i tried with py name="objednavka"+res.user
i get this error :
