#discord-bots
1 messages Β· Page 1047 of 1
@fading marlin can you type for me?
no

you just have to assign your command prefix to your function
Hmm
I have a bot hosted on heroku (I know, not recommended), but it's a small project & has been fine for me, but it's been offline for a couple of hours & I'm trying to track down why, but not sure where to look.. Any suggestions?
Have you run out of free dyno hours?
Hm, I'm not sure, where can I find how many I have?
@slate swan Keep it server-appropriate please.
Not out of hours, have 212 left
we have to see some code ofc, just errors don't help us that much
hey, i use replit and the repl keeps turning off despite me having a keepAlive.py file setup
Are you using replit for hosting?
hello ! so, i get something wired when trying to read the embed of another bot using discordpy/nextcord.
i found a stack overflow post of someone who seems to have the same problem as me but there are no answers to it
https://stackoverflow.com/questions/67362140/how-do-i-properly-read-embedded-messages-on-discord
The following code, wich worked some weeks ago when i wrote it; now returns an empty list even if the message clearly contain embeds :
if message.author.id == 678211574183362571:
message_content = message.embeds
print(message_content)
Do you have message intents enabled?
yup
Both in the dashboard and your code?
You have intents.message_content = True in the code?
lemme check
i didn't but apparently it's not a thing
Can I see the code?
@commands.Cog.listener("on_message")
async def message_send(self, message):
if message.author.id == 678211574183362571:
message_content = message.embeds
print(message_content)
Not that, I mean the part where you're setting intents
oh, sorry
no, im using uptime robot
# Intents
intents = nextcord.Intents.default()
intents.guilds = True
intents.members = True
intents.message_content = True
bot = commands.Bot(
command_prefix=prefix,
intents=intents,
strip_after_prefix=True,
case_insensitive=True
)
but the repl turns off an the host shows that its online
So, you're trying to run code 24/7 with replit?
yeah
That explains it
Not really much you can do about it. Replit isn't a host, was never meant to be up for more than a few minutes. Even using something like uptime robot or keepalive it's going to go offline regularly
Replit is for running quick snippets of code to test if something works, not for hosting applications
I see, any reccomendations of what i should use?
check #965291480992321536 pins
alright
Replit is shit
Anyone familiar with heroku? I know it's not much better than replit, but it's been fine for my use case, but it's currently offline and I'm trying to diagnose why. I'm not out of hours, so that's ruled out. Haven't edited the bot and has run fine until today
Anyone know why this prints an empty list? Myself and another person are under the WINNER role. It prints "submissions", "WINNER", "[]" in that same order
channelID = client.get_channel(submissionChannelID)
print(channelID)
role = discord.utils.get(channelID.guild.roles, id=winnerRoleID)
print(role)
pastWinners = role.members
print(pastWinners)```
The goal is to simply get all the members with a certain role
and before you mention get_role, what difference would that make in solving the problem?
can you just print the role object?
print just the id?
Im printing the role on the 4th line if thats what you mean
it prints "WINNER" which is the role
show me
Do you have member intents passed to your bot?
I gave it administrator
Permissions isn't the same thing as intents
You'll need to pass member intents to your client in order to see the members
what are 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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
oof
Okay thanks
Okay well I enabled intents on the dev page
and added the code ```py
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True```
hold on I think I realize whats happening
Ok yeah I sort of got it but Im getting a long string of information
[<Member id=231489473782942624 name='Person' discriminator='3323' bot=False nick=None guild=<Guild id=938266082182037594 name='bot testing' shard_id=None chunked=True member_count=3>>, <Member id=317342921739206656 name='coolbeansdude' discriminator='4877' bot=False nick=None guild=<Guild id=938266082182037594 name='bot testing' shard_id=None chunked=True member_count=3>>]
Any way I can just get the users ID?
hi
Quick question about working with sqlite3 in python for discord, do I need to wrap my attributes in quotes when defining their variables in order to fix this? I understand using all text fields is not good practice but just trying to get an understanding first.
Table Create
class MemeSubmission(commands.Cog): # declaring the listener cog for async events
#initialize cogs
def __init__(self, bot):
self.bot = bot
self.bot = bot
self.db = sqlite3.connect('memes.db')
self.create_tables()
def create_tables(self):
cur = self.db.cursor()
cur.execute('''
CREATE TABLE IF NOT EXISTS memes(
messageid text PRIMARY KEY,
userid text NOT NULL,
username text NOT NULL,
timestamp text NOT NULL
)
''')
self.db.commit()
Insert Values
embmsg = await msg.channel.send(embed=embed, file=file)
await embmsg.create_thread(name=thread, auto_archive_duration = archive_time)
messageid = embmsg.id
userid = msg.author.id
username = msg.author
timestamp = msg.created_at
cur = self.db.cursor()
cur.execute("INSERT INTO memes (messageid, userid, username, timestamp) VALUES (?,?,?,?)", (messageid, userid, username, timestamp))
self.db.commit()
await msg.delete()
I'm assuming its just the datatype of userid, so thats why im wondering if its best to declare as string.
ERROR:
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/memes20/venv/lib/python3.8/site-packages/discord/client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "/home/runner/memes20/cogs/listeners.py", line 64, in user_message
cur.execute("INSERT INTO memes (messageid, userid, username, timestamp) VALUES (?,?,?,?)", (messageid, userid, username, timestamp))
sqlite3.InterfaceError: Error binding parameter 2 - probably unsupported type.
ξΊ§```
sqlite3 is most likely having issue with username since you've given it a discord.Member object which is not a data type it supports; to fix it you should pass a string as the parameter like msg.author.name
oh that makes sense
going to try it
and that was it, im dumb. makes total sense thankds
also their username might change over time, so usually its easier to store just their user id
with that you can mention them with the format <@id> or get/fetch the user whenever you need their name
makes sense, thanks! done
god I hate sqlite syntax as someone who works with both postgres and mysql
you might also want to check out an async wrapper of a database
note that you'll have to also initialize that attribute (self.db) asynchronously in a startup task or whatever
so im initializing in a cog class then inserting further down in an actual cog as part of a listener event
class MemeSubmission(commands.Cog): # declaring the listener cog for async events
#initialize cogs
def __init__(self, bot):
self.bot = bot
self.bot = bot
self.db = sqlite3.connect('memes.db')
self.create_tables()
def create_tables(self):
cur = self.db.cursor()
cur.execute('''
CREATE TABLE IF NOT EXISTS memes(
messageid text PRIMARY KEY,
userid text NOT NULL,
username text NOT NULL,
timestamp text NOT NULL
)
''')
self.db.commit()
@commands.Cog.listener("on_message")
async def user_message(self, msg):
gallery = 952973551948922949
thread = (f'{msg.author.name}\'s Dank Meme')
archive_time = 60
if msg.author == self.bot.user: #bot doesnt listen for itself in user_message
return
if msg.channel.id == gallery:
if not msg.attachments:
await msg.delete()
return
attachment = msg.attachments[0]
if attachment.filename.endswith(".jpg") or attachment.filename.endswith(".jpeg") or attachment.filename.endswith(".png") or attachment.filename.endswith(".gif"):
file = await msg.attachments[0].to_file()
file.filename = 'image.png'
embed=discord.Embed(description=msg.content)
embed.set_image(url='attachment://image.png')
embed.set_author(name=msg.author, url=msg.author.display_avatar,
icon_url=msg.author.display_avatar)
embed.set_footer(text=msg.created_at)
embmsg = await msg.channel.send(embed=embed, file=file)
await embmsg.create_thread(name=thread, auto_archive_duration = archive_time)
messageid = embmsg.id
userid = msg.author.id
username = msg.author.name
timestamp = embmsg.created_at
cur = self.db.cursor()
cur.execute("INSERT INTO memes (messageid, userid, username, timestamp) VALUES (?,?,?,?)", (messageid, userid, username, timestamp))
self.db.commit()
In Main.py file:
intents = discord.Intents() #these are the discord intents and you MUST TURN THEM ON IN YOUR DISCORD APPLICATION
bot = commands.Bot(command_prefix = "?", case_insensitive = True, intents = intents.all())
bot.remove_command('help')
# BUTTON VARIABLES
@bot.event
async def on_ready():
print('Logged in as {0.user}'.format(bot))
async def load_extentions():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
async def main ():
async with bot:
await load_extentions()
await bot.start(os.environ['botsecret'])
asyncio.run(main())
is this not a good way of handling it @potent spear?
ignore some of the comments in main, forgot to delete them from when I was sharing my code with someone earlier and have since redone a few things.
but my understanding is with this way of doing it I am initializing db whenever the listener cog itself initializes, so if I want to access the db outside of this cog, I may need to reinitialize, but I dont think its an issue unless im missing something obvious.
if you only have to use your db in that cog, then you won't need to initialize the db variable in the main file, else you do
lastly, small typo load_extensions
woah didnt even notice the typo. whats scary is I think I copied and pasted that same code with the typo from another bot of mine and its running in a server right now and I havent noticed anything go wrong. wonder what issues its causing lol.
whats wrong with load_extentions()
If I also wanted to use it in another cog would I just move it from init on the cog and put it in main and remove 'self'?
the second t should be an s
oh, you mean in terms of spelling~
yup
should not effect code-wise though
.
just attach that property to bot instead of cog in the init itself
then you can use a context manager around the bot context manager
async with ... as db:
async with bot:
...
bot.db = db
...```
@potent spear i like your stress reducer ^_^
stolenI came up with the idea myself
never actually used context manager π¬ not sure if im understanding. so instead of:
#this is in cogfile.py
class MemeSubmission(commands.Cog): # declaring the listener cog for async events
#initialize cogs
def __init__(self, bot):
self.bot = bot
self.db = sqlite3.connect('memes.db')
self.create_tables()
def create_tables(self):
cur = self.db.cursor()
cur.execute('''
CREATE TABLE IF NOT EXISTS memes(
messageid text PRIMARY KEY,
userid text NOT NULL,
username text NOT NULL,
timestamp text NOT NULL
)
''')
self.db.commit()
it would be:
intents = discord.Intents() #these are the discord intents and you MUST TURN THEM ON IN YOUR DISCORD APPLICATION
bot = commands.Bot(command_prefix = "?", case_insensitive = True, intents = intents.all())
bot.remove_command('help')
#-----------------------------I put this here in main.py
async with sqlite3.connect('memes.db') as db:
bot.create_tables()
def create_tables():
cur = bot.db.cursor()
cur.execute('''
CREATE TABLE IF NOT EXISTS memes(
messageid text PRIMARY KEY,
userid text NOT NULL,
username text NOT NULL,
timestamp text NOT NULL
)
''')
bot.db.commit()
is that right?
no, you only use the db context manager in main.py in your main() function
then you can access the db through bot.db from anywhere your bot is
like this?
async def main ():
async with sqlite3.connect('memes.db') as db:
async with bot:
bot.db = db
await load_extentions()
await bot.start(os.environ['botsecret'])
asyncio.run(main())
you're using sqlite, use an async wrapper to make the async make sense
where do you even get ctx.server from? that's old asf
so something like aiosqlite yeah?
absolutely correct
ill give it a shot, thanks.
you'll need to use await db.execute() etc too then
wdym you don't know? did you even write it yourself?
got it, Im not 100% sure if I understand how this will affect referencing DB in multiple cogs but im going to do my due diligence first and try to figure it out
you don't need to do anything anymore relating the db in the init of a cog that way
by googling on stackoverflow or what? you should use the official docs
well then you got some wrong help, for getting the server using Context, you need to use Context.guild
.server is a thing which has been replaced with . guild long time ago iirc
umm how can i get the output in ## hours: ## mins and ## seconds from
import time
start_time = datetime.now()
await ctx.send(f"{datetime.now() - start_time}")```
instead of 9:55:53.037107
you'll have to look at .strftime
i doubt if timedelta s have a strf
you probably want something even more sexy like
<t:1652658203:R>
Nope
Hi, it's possible call a command with another command using cogs?
For example a command that send a dm to a specific user and invoke another command that bans the user
yep
ofc, invoke is what you're looking for
you can use Bot.get_command("command name").invoke @winter meadow
channel is a string, you obv can't do +1 on that
Thanks, i'm going to try that
and now in english
can you put the thingie into the code brackets so I can see how it works
what is this for? cause that looks kinda sus
yea~
<t:1652658950:R>
<t: timestamp integer:R>
the timestamp integer for you would be int(bot.start_time.timestamp())
i got <t:2022-05-15 20:00:20.038248:R>
as a message in the channel
@slate swan
you need a TIMESTAMP, not a datetime string or object or whatever
how can i generate the timestamp interger lol
that's something you can google
it's an attribute of datetime
it's called usually "unix timestamp" or "epoch", this is how usually time and date is stored internally
well i used the datetime.timestamp(datetime.now) and it gave me
<t:1652659774.783313:R>
idk where the decimal came from
you have to round the timestamp
how do i round it lol
that's a question you can google
you're too new to try a library like this
learn basic python first
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
Instead of doing all this manually, just use this util method
i used the round() function
Okay?
it worked for me. thx
wait is there a way to get hours minutes and seconds in one timestamp?
instead of the count of the largest item in the timestamp
i don't think there is
T (9:41:34 PM)
For example
so <t:integer:T>
i think he meant like "10 hours 3 minutes 24 seconds ago"
yep. is there a way to at least format my previous code?
this^
@bot.command**()**
delta = datetime.now() - start_time
days, hours, minutes, seconds = delta.days, delta.seconds // 3600, (delta.seconds // 60) % 60, delta.seconds % 60
yo
my bot is timing out because of the 3 second timeout thing
I can't really get the response to be under 3 seconds
is there a way to "respond" outside of a reply?
and what do i send? because idk what is happening there lmao
send f"{days}days {hours}h {minutes}m {seconds}s ago" ... or edit this anyhow you want to
ok thanks man
are you still around? Im having a bit of trouble but I know im close
What is the doc for setting a bots status?
you know other members are equally as talented?
change_presence is what you're looking for
nvm then, was just asking because you knew the context
ok and how do i create a task to update it every minute or so
you'd want to make it every 5~10 mins to not get ratelimited
first learn how to make and start a task
then add that code to change a status inside
@commands.is_owner()
@commands.command()
async def blacklist(self, ctx, guild: discord.Guild = None):
if guild is None:
await ctx.send('missing arguments')
db = sqlite3.connect('astral.db')
cursor = db.cursor()
cursor.execute('SELECT guild_id FROM whitelist WHERE guild_id = ?', (guild.id,))
data = cursor.fetchone()
if not data:
e = discord.Embed(
description=f'{ctx.author.mention}: `{guild.name}` is not a **whitelisted** guild',
color=0xf8a424
)
await ctx.send(embed=e)
if data:
cursor.execute('DELETE FROM whitelist WHERE guild_id = ?', (guild.id,))
e = discord.Embed(
description=f'{ctx.author.mention}: `{guild.name}` has been **blacklisted**',
color=0xa8ec7c
)
await ctx.send(embed=e)
db.commit()
cursor.close()
db.close()
This is not deleting what it needs to delete from the database. I'm doing this on my test bot where everything is setup correctly. On my main bot it does work.
Anyone an idea on why?
There are no errors
what is the doc you reccomend for tasks?
the documentation of the library should be known to you...
if not data:
...
if data:
...
that's just an else statement pls
you should just check till where the code runs
I know it is, but for me this is easier to recognize if I need to change something
And it doesn't affect the code
doesn't make much sense
use else...
if not data:
..
else:
?
yup
alr
also, you should only commit in the else statement, there's not even a db execution in the if
i am only commiting in the else statement?
It's checking if there is data in the column, if there isn't it'll send a certain message, if there is it'll delete it and then it'll commit and close
or you mean tab it one more time?
anyway, all of this doesn't help me with my actual problem
just debug it, then all should be clear...
aka, you should know till where the code runs and what it does that you didn't expect it to
since just thinking "ah shit, it didn't delete, something is wrong" isn't sufficient
Even when debugging it doesn't show anything
This is the exact code that I use for my main bot and I'm just changing embeds, basically giving it a nicer style of everything
and it works on my main bot, but not on my testing bot
that's irrelevant
does the command even run?
yeah it does
hence why i'm confused on why it doesn't work
at least the deleting part
what have you tried?
tried to print out errors if there are any, but nothing shows up
And also using the debug tool from pycharm itself normally shows me what's going on
show me
Even that didn't detect anything
just where you tried to print etc
do you have any on_command_error event? or on_message event?
I have a global error handler
But I can make one just for the command real quick
well, that explains it all
here's the fix:
? how come
add
else: raise error to that event and the error will smile back at you
since you're only handling the errors you want, the other errors get hidden, you have to handle those too
this is currently my global error handler
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
ignored = (commands.CommandNotFound, commands.UserInputError)
if isinstance(error, ignored):
return
if isinstance(error, commands.CommandOnCooldown):
m, s = divmod(error.retry_after, 60)
h, m = divmod(m, 60)
if int(h) == 0 and int(m) == 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(s)}** seconds to use the **{ctx.invoked_with}** command!')
elif int(h) == 0 and int(m) != 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(m)} minutes** and **{int(s)} seconds** to use the **{ctx.invoked_with}** command!')
else:
await ctx.send(
f' {ctx.author.mention}, you must wait {int(h)} hours, {int(m)} minutes and {int(s)} seconds to use the **{ctx.invoked_with}** command!')
elif isinstance(error, commands.MissingPermissions):
missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in error.missing_permissions]
if len(missing) > 2:
fmt = '{}, {}'.format(", ".join(missing[:-1]), missing[-1].lower())
else:
fmt = ' and '.join(missing)
_message = '{}: **{}** requires the `{}` permissions'.format(ctx.author.mention, ctx.invoked_with,
fmt.lower())
e = discord.Embed(
description=f' {_message}',
color=0xffd33c
)
await ctx.send(embed=e)
raise error
I don't see an else
comment out the whole error handler and try again
Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Users\ego\anaconda3\lib\site-packages\discord\client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "C:\Users\ego\Desktop\beta\cogs\aevents.py", line 17, in on_command_error
raise error
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\bot.py", line 1325, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 940, in invoke
await self.prepare(ctx)
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 862, in prepare
await self._parse_arguments(ctx)
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 769, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 640, in transform
return await run_converters(ctx, converter, argument, param) # type: ignore
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\converter.py", line 1297, in run_converters
return await _actual_conversion(ctx, converter, argument, param)
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\converter.py", line 1179, in _actual_conversion
return await converter().convert(ctx, argument) # type: ignore
File "C:\Users\ego\anaconda3\lib\site-packages\discord\ext\commands\converter.py", line 723, in convert
raise GuildNotFound(argument)
discord.ext.commands.errors.GuildNotFound: Guild "924718798286761994" not found.
there you go
Guild not found, even tho the guild is in the database
I hope you're storing the guildID as an integer in your db
I am
just debug, you don't even need dpy for this, make a small test file where you do sql statements or whatever
alright
i'll get to it later, thank you for helping!
ah actually, i think i figured it out. it's because the bot isn't in the guild.
that's why it isn't blacklisting the guild from the bot
im having some trouble successfully writing to a DB file in a cog after making some changes to utilize a single DB connection in async sqlite throughout my bot. Im able to creates tables and write to them but Im getting a corruption issue:
This is in main
async def load_extentions():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
async def main ():
async with aiosqlite.connect('memes.db') as db:
async with bot:
bot.db = db
cur = await bot.db.cursor()
await cur.execute('''
CREATE TABLE IF NOT EXISTS memes(
messageid text PRIMARY KEY,
userid text NOT NULL,
username text NOT NULL,
timestamp text NOT NULL
)
''')
await bot.db.commit()
await load_extentions()
await bot.start(os.environ['botsecret'])
asyncio.run(main())
This is in a cog class
embmsg = await msg.channel.send(embed=embed, file=file)
await embmsg.create_thread(name=thread, auto_archive_duration = archive_time)
messageid = embmsg.id
userid = msg.author.id
username = msg.author.name
timestamp = embmsg.created_at
cur = await self.bot.db.cursor()
await cur.execute("INSERT INTO memes (messageid, userid, username, timestamp) VALUES (?,?,?,?)", (messageid, userid, username, timestamp))
await self.bot.db.commit()
Im not getting any errors but my DB file is being corrupted on both table creation and on write (probably from the creation though). I figure I shouldn't be referencing the connection in the way that I am in the cog, but I dont know 100% if that's related.
ah ty, bot.logout seems to work maybe as well, il give both a try
They both do the same thing.
How can I specify embed color when doing discord.Embed.from_dict?
how to get all animated emoji ctx.guild has?
can u explain im not sure what to do? i also have time to compare
Any way on how I can reset a member their nickname? So it'll just delete the nickname if they have one and it'll show their discord name instead
member.edit(nick=None)
thank you
!d
discord.Member.edit
await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the memberβs data.
Depending on the parameter passed, this requires different permissions listed below...
How exactly do I get just the discord ID from a user object?
wow okay thank you lol
NP
wondering if anyone sees anything obvious that im doing wrong here. All was working fine when I had things initialized within a cog before switching to aiosqlite and moving this stuff to main.
Did you try asking in #databases
Sounds like more like a database problem
yep, ill keep troubleshooting in the meantime, thanks
You did
how can I replace the .webp to .png in the user.avatar_url ?
Another question, I can't find this anywhere online; how do I retrieve the amount of reactions of 1 specific reaction on a message?
Okay I found message.reactions
if u mean like in embeds i think its .url lol
I get this when I select an option
The embed is edited but the bot sends this
Code?
ive had it before and i fixef it but i cant come off with it the top of my head, but i think its you choose thr thing you want to send
or topic
are you sending an embed?
show code lol
view = View()
view.add_item(select)
ctx = await ctx.send(embed=helpEmbed, view=view)
async def my_callback1(interaction):
if select.values[0] == "Fun Commands":
await interaction.response.send_message(await ctx.edit(embed=e2))
if select.values[0] == "Server Related Commands":
await interaction.response.send_message(await ctx.edit(embed=e4))
if select.values[0] == "Utility Commands":
await interaction.response.send_message(await ctx.edit(embed=e5))
if select.values[0] == "Moderation Commands":
await interaction.response.send_message(await ctx.edit(embed=e3))
select.callback = my_callback1
Yes
and thats the reason you dont make your own help command and subclass the default help command
Nvm Iβll use ephemeral messages for embeds
Cuz it works with embeds
why are you editing while sending-
nor does interaction accept a Message object
which edit returns
is this discord.py?
yes
Ah okay, well I don't believe that's the correct way to deal with select menus
ill go with this
https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py here's the example I wrote, hopefully it helps
heroku disabled hosting for github code so does anyone know any free hosting services i could use for my bot
heroku ClI
is that different from Heroku?
because they had a security breach from github and stopped supporting all code from it like a month or 2 ago
replit?
No
Self host
@supple thorn
What
get raspberry pi and self-host
see the replied message
Yeah so
?
@heavy shard how hard is it to do that because i have one
hmmm depends on how well do you know linux
for member in member_mentions:
if isinstance(member, disnake.Member):
if GLOBAL_CODM_ROLE not in member._roles:
count += 1
res.append(member.mention)
if not isinstance(member, disnake.Member):
unkwown_count += 1
unkwown_names.append(str(member))
not_found = "\n".join(unkwown_names) if unkwown_count != 0 else ''
I have this code and not_found seems to return a list of all disnake.Members basically everyone who was mentioned in the message why?
is it public guild message?
it's supposed to return the empty string because all of them are in the server
yes
You mispelled unknown_count
why are you using member._roles, you dont want to play with the internals unless you know what it is
Or did you actually intentionally mispell it
where?
yeah i am aware
i thought about it, and just decided to use it
You named it as unkwown_count
I'm starting to think that's intentional
fair enough if you want to use it like if 1234563545 in member._roles
it is ```py
unkwown_count = 0
unkwown_names = []
if message.channel.id == GIVEAWAY_CHANNEL_ID:
for member in member_mentions:
if isinstance(member, disnake.Member):
if GLOBAL_CODM_ROLE not in member._roles:
count += 1
res.append(member.mention)
if not isinstance(member, disnake.Member):
unkwown_count += 1
unkwown_names.append(str(member))
not_found = "\n".join(unkwown_names) if unkwown_count != 0 else ''
Also unkwown_names
Why
yeah the var is GLOBAL_CODM_ROLE = 628732834336735232
what do you mean why?
π
Why is it named unkwown instead of unknown
Sarth help
so by your code i can process that members in the member_mentions variable are not discord.Members
U misspelled unknown :p
or are they
he's just talking about the spelling mistake you made
Your unkwown variables are mispelled
I'm asking why
member_mentions is member.mentions
i mean message.mentions
yep
which list exactly?
your member.mentions list
but how will that show if it's a disnake.Member though?
@client.command()
@commands.has_permissions(manage_messages = True)
async def channel(ctx,channel: discord.TextChannel,message):
await channel.send(message)
How can we make that bot also send name of person who used this command . Pls tel
for member in member.mentions:
print(member)
```something like this?
await ctx.send(ctx.author.name)
yeah, how is that going to show if it is a member
I want send author and message both
i probably should just iterate through and print the disnake.Members
It's only author name but i want it send message also
use formatted string
Me new at discord.py idk how to
[member for member in member.mentions if isinstance(member, disnake.Member)]
await ctx.send(f'{ctx.author.name}, {message}')
Ok
its basic python?
No
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
i wouldn't travel by that plane π
@loud junco will it work if i do it like this
await channel.send(f'sent by-{ctx.author.name},message-{message}')
tell ur expected output
I think yes
??
i mean tell what u are trying to output
sent by-HydroRICO1209,message-hello world
I mean that it send message-{message} and sent by-{author}
Ye
this is the output if message = 'hello world'
hey guys I need some help.
I basically have a command that pulls a random image from reddit and display it in the channel. The issue is some websites images wont embed itself into discord.
So, how can I add a check if it's from certaindomain to not send the image and get another one from reddit?
Ye
then u can
And i use this command %send #anychannel hello all
My bot only sends hello it not send other words
you need "hello all" <-- in quotes
How to make the additional_param optional? Like we can have it or leave it blank.
@bot.command(name = "test", help = "test")
async def test(ctx, param1, param2, additional_param):
#something
Hmm can you tell what will be the code
Here is my code
it's not the code, you need to use command like that %send #anychannel "hello all"
Oh k
yeah or u could just add a * operator before the message param or whatever it is named
then he's gonna need to parse the channel manually
no? what do you mean
or will it work like that? dunno to be honest
async def channel(ctx, channel: discord.TextChannel, *, message):```
How can we use user string like
dm(ctx, (userstring),message)
Pls tell how to
your message is already the user string I think that's what you mean
No
Like we can %dm @robust fulcrum (message)
So what will be the string at the name
like the person who wants to dm?
ye
add the argument member: discord.Member
Id use
async def dm(ctx, member: discord.Member,*, message):
await member.send(f'**{ctx.author.name}** said: {message}')
it's better to have an error handler for this one, as it is a command the argument passed could not be a member
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/features/python.py", line 151, in jsk_python
send(await self.jsk_python_result_handling(ctx, result))
File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/features/python.py", line 101, in jsk_python_result_handling
result = repr(result)
File "/app/.heroku/python/lib/python3.9/site-packages/discord/scheduled_events.py", line 230, in __repr__
f"<ScheduledEvent id={self.id} "
TypeError: __str__ returned non-string (type Object)
``` i'm getting this error with
```py
ctx.guild.scheduled_events
pls ping me if you can help asap
!pypi heroku
π
bro?
it's just hosted on heroku bruh and it has nothign to do with error
Oh yeah other lib was hikari kinda confused.
π alright
Anyhow you have the intent on?
does it require intent? π
which one tho? π didn't know that we need intent for schedule event
!d discord.Guild.scheduled_events
property scheduled_events```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of the guildβs scheduled events.
New in version 2.0.
it does return list when there is no event in server
^^^ an empty list
but when ther's one.. i'm getting this..
.default should cover the intent tough.
i've default one alreaedy
Yeah okay
This error doesn't appear to be an issue on your end, do you have some more code?
π i sent the traceback actually
that's all there is to it
Hmm lemme ask in dpy
for proof
Lol why sending the whole traceback as response of the command
update your dpy bro @slate swan
btw show the full code block
discord/scheduled_event.py line 163
return f'<GuildScheduledEvent id={self.id} name={self.name!r} guild_id={self.guild_id!r} creator={self.creator!r}>'```
last updated when?
Oh fuck im out.
π lmfaoo
alright, taht's okay
py-cord... most likely the issue lies there.
thats jishaku, they probably did an eval on discord~
^^^
Since they just copy paste every new update of dpy without testing.
π€ tbh... i'm just not sure about danny.. i'm kinda afraid if he discontinue the project dpy again
like.. i do believe him..he's good, but still uk
kinda the reason why i'm not using dpy π
use disnake then 
It's fairly easy to hop between libraries.
π© it is easy, but it's not easy to 're-write' your whole bot uk
like.. too much work .. lmfao
i got the fix yay
Not really since it is a fork 
owo
fix of? πΎ
Yeah going from pycord to dpy is the most easiest when comparing to disnake or nextcord.
go to scheduled_events.py , __repr__ property, they are returning a tuple, use " ".join() on that tuple and you are fine @slate swan
you're the best bro thanks π©π
noted, will give a thought about it
:>
imagine not digging into the source code and monkey patching it
i dig into the source code to verify or find some curiosity about the code
You're just holding ctrl+c ready
I've never really modified any package I'd just find another solution or code my own.
that's just reinventing the wheel
Wheel is like 20 lines anyways.
and you want to make that 50? xd
Yeah but i'm too lazy to make calcs with hex or binary, but people who make those package have C mentality so the binary part is good and everything else is thresh
You can also just use inspect or subclass to overwrite functions.
how can i make that the bor create a channel in a specific kategorie
you get the category object
then use .create_text_channel() on that object
the create_text_channel has a category kwarg iirc
in fact it his a guild method
yup, you can choose
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission
to create the channel...
you was faster xD
either you pass the object as a kwarg, or you just use the object and call the method on that
Have i put the name or the id in category=None?
the object
category (Optional[CategoryChannel]) β The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.
create_text_channel doesn't work
why
i have made bot.create_text_channel but "bot" object has no atribute create_text_channel
it's a method of discord.Guild, not commands.Bot
is guild.create_text_channel korrect?
yup
now name guild is not definied
that's logic ofc... in your case, it's ctx.guild
any way to get someone's server avatar?
!d
discord.Guild.icon
property icon```
Returns the guildβs icon asset, if available.
now name ctx is not definid
whats the issue
i know what i do wrong
No i thougth i know. I don't make it in a command i made it in an om_messge event
ctx doesn't work
what do u want
if the bot got an dm he create an channel
u need to add the guild id
i did it to make that the bot send the message in a specifik channel
ok so u want like if user dm the bot bot makes channel only on a specific guild?
Yes
yes
.
i can't copy the id because i'm on mobile in the browser but i guess if i'm on my computer i can do it
huge thanks
you can still get the guild id...
@commands.dm_only()
can you tell me how?
print all the guilds...
ok i try it
@bot.command()
@commands.dm_only()
async def s(ctx):
g = bot.get_channel(id) or await bot.fetch_channel(id)
await g.send("hi")
something like that
add fetch if u want
thanks
my bot has been rate limited since 10 hours ago(at least)
and now its still rate limited :D
gg
I wonder why
replit being replit
oh
LOL
next time you will buy a vps for hosting your things 
What if he's broke 
how do i hide certain cogs in commands.HelpCommand?
ikr
I mean the server profile that a user has in some guild
not implemented yet, I'm not so sure
kekw
first of all have you learnt python
is there any way to await this? ```py
mapping = dict(filter(lambda x: x[0] and ctx.bot.cog_is_public(x[0]), mapping.items()))
then learn the basic first
before u start discord.py
unless you want to suffer like me
why would u want to await it?
bcz when i ran it, d.py said this line was not awaited
this line works with other forks
what is cog_is_public?
is it a coro?
async def cog_is_public(self, cog: commands.Cog):
return cog.__module__ in self.public_extensions
Why not just make it a def.
and this is public_extensions: ```py
async def setup_hook(self):
self.public_extensions = await self.load_extensions("cogs")
are you running mapping in an aync function?
yes
it works too, but since dpy is async/await library i thought of doing that
both works
hmm u can do lambda x: x[0] and (await ctx.bot.cog_is_public(x[0]) for _ in '_')
You do need to define the mapping inside an async env
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\help.py", line 945, in command_callback
return await self.send_bot_help(mapping)
File "D:\Projects\PizzaHat\PizzaHat\cogs_hidden\help.py", line 86, in send_bot_help
mapping = dict(filter(lambda x: x[0] and (await ctx.bot.cog_is_public(x[0]) for _ in '_')))
TypeError: filter expected 2 arguments, got 1
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 990, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: filter expected 2 arguments, got 1
did u put mapping.items() as second arg?
stop using normal commands concepts on slash commands, they are 2 different things.
^
you would have to get that interaction message first, and use .add_reaction on it
and the method to get message varies in all libraries.
oh same person lol nvm
thats not how it works.
^
doesnt this work?
as i said, the method to do that is different for all the libraries.
yeah that should work and its message not messag
interaction = await ctx.respond()
await interaction.message.add_reaction()
ok guys so i have a discord bot where it has a command to create a category for something what it does is make a txt file with the name of the category the user chooses
and the user can also use a generate command and what it does is:
get the second argument which is the category name
with open(categoryname + '.txt' and whatever read type depending on what i need)
however if they get ur user they can get text from any txt file in your pc what can i do ?
how
you mea how to learn the basic?
that won't work π , you have to make an async filter function like:
async def afilter(function: Callable, iterable: Iterable):
for i in iterable:
if await function(i):
yield i
!e
from asyncio import run
from typing import Callable, Iterable
async def coro(i):
return i % 2
d = {1: 2, 3: 4, 2: 4, 4: 6}
async def afilter(function: Callable, iterable: Iterable):
for i in iterable:
if await function(i):
yield i
async def main():
a = afilter(coro, d)
print([i async for i in a])
run(main())
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
[1, 3]
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
just go to youtube
beginner python tutorial
pick the highest view
Not having friends

okay ty
np
panda you dutch?
Yes.
ah
lol
π
So the zen of python applies to you
i will
jk
kills him
dies
funeral
there is fun in funeral
survives the gulag
true
I mean apart from the dead person everyone does come together.
alright alright its getting ot now
Hydro is pretty ot
huh
Not too many gifs staff aren't too fond of those.
okay
ye
deletes it
try to keep it text-only ||if you wanna live here any longer||
but that worked for some reason without giving any errors
it didnt filter
Zalgo: 
i just called the function and got nothing
who is zalgo
*replys with a gif
bans u with a gif
lmao
because its not returning anything ig?
Zalgo is a type of text.
oo
um no, so its tries to call the coroutine, the coroutine returns a coroutine object and the way filter works that if the function returns anything it passes it
so it doesn't work as inteded
!e
from asyncio import run
async def coro(i):
return i % 2
d = {1: 2, 3: 4, 2: 4, 4: 6}
# async def afilter(function: Callable, iterable: Iterable):
# for i in iterable:
# if await function(i):
# yield i
async def main():
a = filter(lambda x: (await coro(x) for _ in '_'), d)
print([*a])
run(main())
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
001 | <string>:15: RuntimeWarning: coroutine 'coro' was never awaited
002 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
003 | [1, 3, 2, 4]
see it returned [1, 3, 2, 4] whereas the output shouldve been [1, 3] (#discord-bots message)
What are you trying to do?
async filter
async def create_role(ctx, *, name):
guild = ctx.guild
await guild.create_role(name=name)
await ctx.send(f'Role `{name}` has been created')```
how can i make it give the role specific perms while creating it?
how do I concatenate a say command? I want it to say "Hello World" when I do ?say Hello World, but it's outputting "Hello" instead
add a * before the argument which accepts a string
You can definitely expand this into a for loop with await asyncio.sleep() at the end of the loop's body
Or you can use asyncio.gather
@bot.event
async def on_member_join(ctx, server: discord.Guild, member: discord.Member):
await ctx.send(f"Ealcome to the server {member.mention}")
await member.send("Welcome to {server}")
await member.add_roles(974273691737288774)```
Tried joining on my alt and nothing worked
Member intents enabled?
also on_member_join only passes you a discord.Member object
how do I enable that?
!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
the new timeout feature in discord.py is member.edit(mute=..) right?
!d discord.Member.timeout
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
@dense swallow ^
"mute (bool) β Indicates if the member should be guild muted or un-muted."
yes, it's mute in VC
I want to make a daily reward for my currency system, BUT idk how i would check if the user has claimed it already at that day.
how to give role to all members?
how do i make like
me: rpm changedata 123
rpm: what data would u like to change '123' to
me: 1993
rpm: changed value of '123' to 1993
async def on_member_join(member):
await member.send(f"Welcome to **{member.guild.name}**")
await member.add_roles(*974273691737288774)
Last thing (Probably) I need, Why isn't the add role thing working? I need this for other things too
why star
I looked on the api reference site and it said to put that I think
@client.event
async def on_member_join(member: discord.Member):
await member.send(f"Welcome to **{member.guild.name}**")
role = discord.utils.get(member.guild.roles, id = 974725693881602079)
await member.add_roles(role)```
how to give role to all members?
im getting an error..
https://paste.pythondiscord.com/detezaqupe
for member in guild.members :
...
any know how to do
me: rpm changedata 123
rpm: what data would u like to change '123' to
me: 1993
rpm: changed value of '123' to 1993
how do i make it ask question and take value
AttributeError: 'NoneType' object has no attribute 'id'
how ping me?
!d Client.wait_for
No documentation found for the requested symbol.
just look up wait_for in the docs
ok
!d discord.Client.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
wait
nvm got it
ping
what is event
event?
oo
mb add
intents = discord.Intents.all()
client = commands.Bot(command_prefix="p!", intents = intents)
and turn on intents https://discord.com/developers/applications "your bot"
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
that didn't help I don't think
hm
@bot.command(name='hack')
async def hack(ctx, arg:str):
try:
userid = str(ctx.author.id)
if userid != '757508305256972338':
await ctx.send('**ACCESS DENIED**')
else:
wait_for('mesage', /, *, check=None, timeout=None)
```is this how u do it
I recommend clicking on the url and not copying the function representation.
LOL ok
give me ur imports
Haven't had a single server add since my bot page went live yesterday 
Iβm not in my programming class at school anymoreβ¦ I can give them to you when I get home
def check(message):
return mesage.author == ctx.author and message.channel == ctx.channel
message = await bot.wait_for("message", check=check) #check is optional
#if message received a valid response corresponding to the check, it will return a Message object
oh ok
alright
thanks
patience
i think u dont import utils from discord
utils are imported from discord
ty
mine has 100 and i need to wait for 7 months for vertification
edit(content=...)
oh
7 months for verification?
!d nextcord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=..., file=..., files=..., append_files=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
My first one didn't take nearly that long
my birthday is on december and im 2006
File "c:\Users\Akai\Desktop\Sugari\cogs\utility.py", line 33, in callback
await interaction.followup.edit(content=f'```diff\n{mymessage}\n```')
TypeError: edit() got an unexpected keyword argument 'content'
ig followup doesnt take edit()?
or wot?
guys
I want to make a bot that reacts to old messages
Can anyone help?
sayyyyyyy

help
What package are you using?
.....
!d discord.on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is
called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
!d nextcord.Webhook.edit
await edit(*, reason=None, name=..., avatar=..., channel=None, prefer_auth=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits this Webhook.
this is the method that you are calling, you have to pass those args
i was using interaction.response.defer and had to edit it using interaction.followup.send and i was using edit
me noob ikr
@bot.command(name='check')
async def check(ctx, message, arg):
return message.author == ctx.author and message.channel == ctx.channel
message = await bot.wait_for("message", check=check)
```what this does
Guys can anyone help me make a command
Called %pokedex {Pokemon}
Idk how to use APIs (https://pokeapi.co/)
Will anyone help me make this command pls π
you're pretty ahead of yourself... ever made commands before?
try to learn how to use an API first, then implement it in dpy
this isn't really dpy related
Ah, not related to this at all but are public threads only accessible to those who have access to the channels they were made in ?
Sorry for the unrelated question, but i can't test it myself right now..
Idk how to make requests pla help me
There no video on APIs
not related to this channel
But i want to use it in bot
import requests
response = requests.get("https://pokeapi.co/something")
that's the last step
it's like asking how to run before you can even walk
i want get 2 things from api
I want get Pokemon and it's gender from api
nevermind
@potent spear was right
Please read the PokeAPI docs, and learn how to use the requests module
from the json response you get you would have to use data.get("name") for name, data.get("gender")
actually gender wont work*
If i use gender = https://pokeapi.co/api/v2/gender/{Pokemon}
Me not understand what you Mean
But ik about apis
you know what kind of data that api returns right?
that endpoints just returns all the pokemons of that gender
just think about it, pokemons can be male or female , how are you supposed to get the gender of that'
its like Askin the "whats the gender of humans"
Will you help me to make command for it
I'll learn about it slowly actually I have to make the command fastly
I want to make a comamnd %pokedex (any Pokemon name here)
And it get me picture , gender , ability and it's location
ok
Will you help me?
that's not difficult
But me don't know how to
are you using replit?
So first what I have to do
import requests?
requests and json
Done
π
response = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}") data = json.load(response)
aiohttp
huh? wouldn't that use aiohttp
aiohttp π’
aiohttp 
and await response.json()?
use what you want
Well 1. json.loads or response.json() 2. Aiohttp is better for discord bots
opening a new session for each request π
Done
aiohttp is async, requests is blocking
literally what i said
π
im running a vpn along with a script programmed to crash my pc
What I do next?
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
and......?
i cannoy taype
god why are my messages taking so long to send
no comments
Dont. Use. It. Then. ?.
Because it's repl it
@glad cradle what I have to do next?
Sasukeeeee, so long
Me on mobile .-.
but how-
Bruh
nvm
Hello
me too
I have a question:
How can I make 2 different on_member_join events for 2 different servers? If I made them the bot sends both to both servers i tryed it with if guild_id == βIdβ: but It didnβt work
cope
Id should be an int not string
if member.guild.id == guild1_id:
Bro will you tell me next step?
Thanks I try it

follow aiohttp suggestion
Like this
@client.command()
async def pokedex(ctx , pokemon)
response = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}")
data = json.load(response)
Idk what you mean
aiohttp = betterrequests
But how to use it
@client.command()
async def pokedex(ctx , pokemon)
response = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}")
data = json.load(response)
I made it like this
What's next to do
Can anyone tell me steps to do it
I not understanding
Pls tell how can I use it in
@client.command()
async def pokedex(ctx , pokemon)
response = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}")
data = json.load(response)
Cak you tell me steps to make a command %pokedex (Pokemon name)
Which sends me Pokemon picture , gender , ability , location
https://pokeapi.co/api/v2
With this api
Pls help
read the docs
requests is good too
But blocking
read again Ashley
That too
out of context of discord bots
...
nvm im dumb
"no one ot'd me so Imma ot Hunter"
As if I care
Will anyone help me make the comamnd pls
What command
yes
@client.command()
async def pokedex(ctx , pokemon)
response = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}")
data = json.load(response)
This command
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
a : is missing
Idk what to do next
Yo someone wanna help me make a welcome bot?
mmmnooo....
!d discord.on_member_join @slate swan
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Very easy
only if you ask questions here about what you don't know how to do
lmao
Hey will anyone help me make a %pokedex (any Pokemon name )
Command
Which will send me Pokemon image , gender , ability , location
With https://pokeapi.co/api/v2/pokemon api
Pls help make it
I will learn about it lator
U have any js servers I can join?
I think that i will send a pull requests for the Python bot which answer automatically at common question
Not viable tbh
It can become annoying when that's not the answer to the question and the bot repeatedly sends that
There is a package that can check sentence similarity, with that it will be easy to not answer randomly
Ah, cool
yeah imagine the bot just tells a guy with an http error to restart the pc
Well i mean to answer to question like "How to send a message" and the bot will answer with the doc reference of the send method and will explain which object can use that method
something like that
and how does the bot know if it was a question
Looks a good feature tho
if someone is lazy writing
I didn't put a question mark now either
As i said there exist some packages which can check sentence similarity
Machine Learning and eating all the VPS's resources! π
AWS has a ML service that can tell the tone of a sentence
Ngl we would LOVE to see it in action
(I would, at least)
exactly
IIRC itβs AWS comprehend?
yes
cool yeah, thatβs what youβre looking for then
my internet's gone
there is even a package which checks sentence similarity based on the pronounce of words
there are a lot of possibilities
it was not an answer to your question
or do you see the same thing I do
?
Yeah?
Now I will really start studyin' it 
and I lost the context
!pypi pokelance
An async API wrapper for pokeapi.co
How can I rename my bot help command to sth else ? Like !bothelp instead of !help
Because many bots are using !help too I dont want them to show up
@slate swan \π
That means you need to change your prefix to something other bots donβt have
Not a command name issue
Either that or move to slash commands
Hi Dick Grayson
But the same will happen with slash commands if other bots have "help" as command right
Kek
/help
no they can choose which bot's help command they wanna run
Hello there!
No, since discord forces you to pick
Multiple bots having same command name with slash commands is not a problem
Since the UI indicates which command belongs to which bot
Do I have to install a package
Discord.py v2.0 natively supports slash commands
commands.SlashCommand()?
Hate doc lol
Well⦠being able to read documentation is important
I only found slash command package
Will anyone help me make this
Why? Discord py has slash commands
Can anyone tell me steps to make a command %pokedex (Pokemon name)
Which sends me Pokemon picture , gender , ability , location
https://pokeapi.co/api/v2
With this api
Pls help
use requests
I found nothing, only discord-py-slash-commands
Means how I make
search up api's and requests
Idk how to use them
No, discordpy has support
You donβt need to look for any packages
You donβt need to install anything, it works out of the box
aiohttp, requests is blocking
is blocking?
Yes, requests is blocking
Can you share a code snippet please
Will you help me make it
Check the GitHub for examples
wym by thatr
Ye
ok
Itβs very liable to crash your bot
Aiohtto
But idk how to use aiohtto
Cak anyone tell me steps to make a command %pokedex (Pokemon name)
Which sends me Pokemon picture , gender , ability , location
https://pokeapi.co/api/v2
With this api
Pls help
Thatβs why documentation exists
Documentation very hard to understand
Well, you need to learn how to read it
Read aiohttp docs first, then the pokeapi docs
But no one here is helping me make it
I'll learn about it lator i just want to make command now
Read the docs and itβs endpoints, params, etc
Otherwise itβs going to be difficult to make it
But if anyone tell me steps to make I'll be happy and learn about it after making command
I've been trying to count the reactions of one specific emoji on messages and I've been having some trouble.
I found message.reactions
Someone told me I had to get the object of the emoji now... how exactly do I do that?
is the reaction a custom emoji
No its a discord one β€οΈ
Gotta learn the docs before making the command, canβt the other at around
just copy paste the heart, a reaction has an emoji attribute which if you convert to str you can check if it's a heart
if str(reaction.emojj) == "β€οΈ"
But if you can help me pls help
Hi ! I recently started with discord.py and had to move on the v2 to use some features like text input and so on..
I was using cogs previously and had no problem with them before, when I moved to the v2 I had to change how cog were added and it's not working anymore :
How I proceed with v2:
- On my main.py
extensions = ['modules.Bet', 'modules.CustomEvents']
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="$", intents=intents, message_content=True, messages=True)
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await client.load_extension(f"cogs.{filename[:-3]}")
async def main():
async with client:
await load_extensions()
await client.start(BOT_TOKEN)
asyncio.run(main())
And then on each cog :
class Bet(commands.Cog):
@commands.Cog.listener()
async def on_ready(self):
print("Test")
@commands.command()
async def bet(self, ctx):
# myCode
await ctx.send(embed=embed, components=[create, currentBets])
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Bet(bot))
The "on_ready" is working and printing "Test" on launch but commands are not working (no error, but nothing happens)
I spent some hours looking for a solution on this problem but found nothing helping me, any help would be appreciated..
I donβt believe people can help you if you havenβt read the docs yourself and tried it first
Your message intents are turned on in the dashboard?
Had no issue with it before, so I think so
Double check it
i hate replit tbh