#discord-bots
1 messages · Page 714 of 1
and access those attributes via the class.
yes, for class attributes, use snake_case
My code is far away from pep8, it's a big mess
why did you say yes 
i try my best
use a formatter like black (pip install black) to format your code
bump
func and serverstats are underlined yellow in vsc saying that they are not defined?
@tasks.loop(minutes=2)
async def serverstats(self):
guild = self.bot.get_guild(921714401814409227)
stats_channel = guild.get_channel(921720659653054464)
count = len(guild.members)
await stats_channel.edit(name = f'Member Count : {count}')
await func.start(serverstats)
uhh, shouldn't I? Oh I should say "it does"
Do I need to put that bit on a on_ready event?
I'm trying to install flake8 but I don't have idea how am I supposed to use it 😅
you use vscode?
someones trying to figure out how to use tasks loop, and someone dk how to use flake8 or a format provider
i asked if it follows pep8 guildines and you said yes 
noo, do like self.serverstats.start() in __init__ function
yes it does follow pep8?
Cool
altho it still doesnt follow everything pep8 says , but hey you can use it with some module that scans your code and your good to go
what i did ?
true
ye, but non relevant to this channnel
What is an __init__ function?
@tasks.loop(minutes=2)
async def serverstats(self):
guild = self.bot.get_guild(921714401814409227)
stats_channel = guild.get_channel(921720659653054464)
count = len(guild.members)
await stats_channel.edit(name = f'Member Count : {count}')
await self.serverstats.start()

show your cog
its a constructor , show the init
it should have a def __init__(self, bot):
import discord
from discord.ext import commands
from discord.ext.commands import Cog
from discord.ext import tasks
class ServerStatsCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(minutes=2)
async def serverstats(self):
guild = self.bot.get_guild(921714401814409227)
stats_channel = guild.get_channel(921720659653054464)
count = len(guild.members)
await stats_channel.edit(name = f'Member Count : {count}')
await self.serverstats.start()
@Cog.listener()
async def on_ready(self):
print(f"[ServerStatsCog Loaded]")
def setup(bot):
bot.add_cog(ServerStatsCog(bot))
oh yeah
yeah start it there
Ok thanks
and remove await
So like this?
class ServerStatsCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.serverstats.start()
yes
go to settings and search formatting provider, then check if flake8 is there
No worries 👍
looks good 
is there a way to check if its a slash command or not without checking the prefix ?
do you mind explaining that to me in ot?
uh, I have imported get from discord.utils?
stats_channel = guild.get_channel(921720659653054464)
AttributeError: 'NoneType' object has no attribute 'get_channel'
oh are you trying to setup black ?
guild is none
flake8
No
guild = self.bot.get_guild(921714401814409227)
stats_channel = guild.get_channel(921720659653054464)

incorrect guild ID
anyways, change the guild.get_channel to self.bot.get_channel and get the guild from stats_channel.guild
Ok
so that you dont need to get the channel manually
Does it matter if the provided id for the channel is a vc?
idts
👀
yeah, it doesn't matter
don't mind me, I am just editing my profile for the server
as always, nitro flex
How do I find the count now
count = len(guild.members)
AttributeError: 'NoneType' object has no attribute 'members'
guild is None
oh
like I said, guild would be stats_channel.guild
No it's not
Wouldn't it be stats_channel.get_guild()?
stats_channel is a GuildChannel instance, it has guild attribute
bruh
guild = stats_channel.guild(921714401814409227)
AttributeError: 'NoneType' object has no attribute 'guild'
Stats channel is not gotten properly
It's a valid guild id
Try printing your variables
Ok
!d discord.Client.wait_for before you define stats channel
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
!d discord.Client.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
This, not that b4
Stats channel is None
oh really
he should learn how to read
LMFAOOO
ah yea, totally forgotten about that
!d discord.GuildChannel.guild
No documentation found for the requested symbol.
!d discord.TextChannel.guild
The guild the channel belongs to.
It’ s not a method
help?
actually how do you get the bot count in disnake
It’ s unused
Wdym
Wdym by bot count?
bot counts like how much bots there are in a server
not a server, i mean the server the bot is in
[member for member in guild.members if member.bot]
[member for bot.members if member.bot]
ok and something like [x for x in ctx.guild.members if not x.bot] should also show the member count except bots
Bot.members is not a thing ig
It may be a method
Yea a list of such members
And I might have used wrong name
ok but what's the member version of x.bot
False
💀 not what i meant
get_all_members
It’ s a bool
oh
Ig
!d discord.Client.get_all_members
for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") the client can see.
This is equivalent to:
```py
for guild in client.guilds:
for member in guild.members:
yield member
i don't use discord.Client
I have a problem with selenium
Ohh, that returns a generator
is it related to discord bots?
then ask somewhere else
webdriver
this is not the right channel
commands.Bot inherits from discord.Client
C:\Users\arouf\PycharmProjects\Bot\venv\Scripts\python.exe C:/Users/arouf/PycharmProjects/Bot/bot.py
Traceback (most recent call last):
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\arouf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\arouf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\arouf\PycharmProjects\Bot\bot.py", line 3, in <module>
driver = webdriver.Firefox()
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in init
self.service.start()
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 79, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Process finished with exit code 1
this is wrong channel, go ask somewhere else
!d discord.ext.commands.Bot.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
geckodriver not found
Download it first
@slate swan
what is geckodiver ?
Bruh
Geckodriver is used to interact with Firefox binaries
Just the way chromedriver is used for Chrome binaries
Uhh can I know your Firefox version?
ok
How can I get the member count, I receive this error when I try this.
count = len(stats_channel.guild.members)
AttributeError: 'Object' object has no attribute 'members'
``````py
@tasks.loop(minutes=2)
async def serverstats(self):
stats_channel = await self.bot.fetch_channel(925350190016249936)
count = len(stats_channel.guild.members)
await stats_channel.edit(name = f'Member Count : {count}')
put await self.bot.wait_until_ready() at the top of stats_channel = await ...
above it?
yes
hey, I'm trying to get the url of a member's banner
this is my code -
member = message.author
pfp = member.banner.url
I'm getting an Attribute error
I recently installed Discord.py v2.0
the error is?
AttributeError: 'NoneType' object has no attribute 'url'
I was referring SO
and came across this solution
your bot doesnt have the User object fetched
and updated my discord.py to v2.0
member is none or the user doesnt have a banner
can you show a little more of your function?
they dont have a banner.
sure
test it on someone who does 
I do tho
ye
I was testing it on myself
show a little more of your function
async def on_message(self, message):
if message.content == ">banner":
member = message.author
pfp = member.banner.url
i am want to make a function in which if a new user uses a command my bot will send a dm for this
is a database required?
this is what I use to fetch the banner url
Using on_message
😉
Yeah you need a db to store the ids
please dont

i use heroku
You can send a GET request to https://discord.com/api/v9/users/{user.id}/profile to get a user's Banner, Banner color, bio & linked accounts
and json file doesnt like have a good relation with json
the json file resets as soon as the bot relaunches
pip install -U git+https://github.com/Rapptz/discord.py @urban shell
you dont have it installed.
I do
I referred SO
like you're doing rn
I just confirmed with pip freeze
😩
wait why do u have self ?
cogs a using a listener as a command 
the function's pretty big
I don't wanna send the whole thing
and I'm pretty sure that's not the issue anyways
okay
problems?
AttributeError: 'NoneType' object has no attribute 'url'
code?
member = message.author pfp = member.banner.url

what version of dpy are you on?
2.0
banner says this
Returns the user’s banner asset, if available.
so this means that the author doesn't have a banner
also
so maybe if you were to fetch the author, it might get the banner?
how can i read what actions send a request to Discord Bot API and what don't
Traceback (most recent call last):
File "c:\Primary\HawT\main.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
that's very nice
- what IDE are you using
- how have you tried installing discord py?
VS code
yes I have discord.py
Oh lol
I forgot it was a reopened file
I was running it as code
not python file
Understandable
Usually , methods with fetch_ and await methods
huh so adding reactions, sending messages will send a request to discord's api
cool cool
Ofcourse
does this apply to aiohttp fetching?
Note that the await thing was only for discord.py methods
Nah
cool cool
thats not even python
https://discord.gg/djs this server is for python, not javascript.
ok
anyways https://github.com/kaylebetter/bonbons my bot is open source
making bots is boring
kind of wish i had a github account
can bot groups also support @commands.guild_only()
sure why not
they are still a command object iirc
technically they hold the commands
ye ig
They are a subclass of a Command class so they are command objects
Can somebody help me?
I need a command that gives the user role he has in a roblox group.
Also, if possible, for it to change his nickname. Actually, to add (Rank) @amber beacon to his nickname!
Here is the current code I got.
groupID = 9247039
robloxCookie = ""
xsrf = ""
@bot.command()
async def promote(cts, user: int, role: int):
with requests.Session() as group:
# get xsrf, its needed.
group.cookies['.ROBLOSECURITY'] = robloxCookie
xsrff = group.post('https://friends.roblox.com/v1/users/1/request-friendship')
xsrf = xsrff.headers['x-csrf-token']
# Promote user!
url = f"https://groups.roblox.com/v1/groups/{groupId}/users/{user}"
group.headers["Content-Type"] = "application/json"
data = {"roleID": role}
res = group.post(url)
await ctx.send(res.json())
to his discord username?
i mean nickname
to change his nickname just do nick=... in a {discord_member_obj}.edit()
and you can fetch the rank, and make it their nickname with fstrings x]
It is recommended to use aiohttp instead of requests in the asynchronous apps
Change cts to ctx, pretty sure you made a typo
Also better hints exist, I mean
async def promote(ctx, user: discord.User, role: discord.Role)```
In this case discord.Member
but user in this code is supposed to be an integer
await user.add_roles(role)``` to add roles
Hello
its a roblex id right?
url = f"https://groups.roblox.com/v1/groups/{groupId}/users/{user}"
lol
just found it
Uh hold up
sorry
By user you want to give the role to you mean the one who used the command or somebody else?
You kinda mixed everything in code so it confused me sry
No, basically,
I want so when user gets the role in the roblox group, and when he runs !update it gives him the role in discord server with the same name of one he has in roblox group
and if possible, for it to change his nickname like (Rank) @ornate flax
@vale wing
Does roblox have an api?
403
not for me
Nvm
they're all here
https://github.com/matthewdean/roblox-web-apis
This tutorial is part of the ro.py tutorial set. To view more ro.py tutorials and learn more about ro.py, visit the Discord server, main topic, documentation, or GitHub repository. In this tutorial, I’ll teach you how to add Roblox features to your discord.py bots with ro.py, the Roblox Web API wrapper for Python 3. When you finish the tuto...
I used user.display_name but it stilled returned their username even though they have a nickname?
!d discord.Member.display_name
property display_name: str```
Returns the user’s display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
Hmm
Show?
is there a way I can make sticky message?
Sticky?
@bot.command()
async def view(ctx, user: discord.User, *, message=None):
user_id = user.id
username = user.name
char_name = user.display_name
yeah, The message that stays at the bottom of the channel
No you can't
I mean, you could make a bot that re-sends the message and deletes the old message everytime a new message is sent in that channel, but that could break in a few ways
sadly 😭
perhaps I could change the user parameter to discord.Member and use user.nick?
async def suggest(ctx, *, query):
if ctx.author.bot:
return
else:
if "suggest" in ctx.content.lower(
):
embed = disnake.Embed(
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
colour=0x4e5ece
)
channel = bot.get_channel(924998519432036393)
await channel.send(embed=embed)```
```AttributeError: 'Context' object has no attribute 'content'```
ctx.message.content
also, the else statement is useless, remove that line
you're returning in the if statement anyways
ok
where i put that
if "suggest" in ctx.content....
should be
in ctx.message.content...
kk
ayo it worked
async def suggest(ctx, *, query):
if ctx.author.bot:
return
if "suggest" in ctx.message.content(
):
embed = disnake.Embed(
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
colour=0x4e5ece
)
channel = bot.get_channel(924998519432036393)
await channel.send(embed=embed)```
still doesnt work
@potent spear
because you have to do ctx.message.content.lower()
oh
a suggestion command
don't tell me in code language, tell me as a non-dev would say it
"If I say suggest shit" it'll do ...
the if suggest is bullshit, remove that line too
ok what should i put then
just your embed and the channel send shit
also, I don't think a bot will ever use your command, you can simply remove that line, it's only handy in on_message events
async def suggest(ctx, *, query):
if ctx.author.bot:
return
embed = disnake.Embed(
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
colour=0x4e5ece
)
channel = bot.get_channel(924998519432036393)
await channel.send(embed=embed)```
nothing
ok
not in the if statement ofc 🤦♂️
wym
the whole embed and channel etc is in the if statement
... put it outside the if statement
so I'm making a bot which can ask random questions, is there any way to send the question ID in footer like in this picture
ofc... if you have them stored somewhere
I just declared a list in code
i dont know how
BRUH
@commands.command(aliases=['T'])
async def Truth(self, ctx):
tr = ["Test Question 0",
"Test Question 1",
"Test Question 2",
"Test Question 3",
"Test Question 4",
"Test Question 5",
"Test Question 6",
"Test Question 7",
"Test Question 8",
"Test Question 9"]
rc = random.choice(tr)
temb = discord.Embed(description=f"**Truth:\n**{rc}",color=0x2e72e8,)
temb.set_footer(text='footer')
await ctx.send(embed=temb) ```
this is my current code
ik
ignore the image
that's terrible, so your id would be the last character in that string? xd
could you do it 4 me idk how
no,I don't exactly want to do that
bruh, you perfectly know how to get something out of an if statement
I just want to make custom ids
probably but i dont understand properly what to do im not english thats why
or im dum xd
in that case you have 2 options
store the questions in a db
store the questions in a json
! don't confuse one another
a json isn't a db!
it's basic python, you should know
yea i should but idk man, could you or..
bruh, you obviously know that if you return in an if statement and there's code underneath that in the if statement that it'll ofc never run because you already returned...?
it will return if bot sends the message not if a user does
yes, but the code underneath the return is still in the if statement
statement is line?
just select all those lines
and do shift+tab
ok
how many times
once
^
IndentationError: unindent does not match any outer indentation level```
I wanna see all the code in that command
send an ss please, u aren't formatting the code well while sending
kk
... u didn't do what Glitcherz told u to do...
morning yall
🤦♂️
you probably didn't even know what shift+tab did
I highly suggest you to learn python before doing such projects
i did but kinda forgot everything
Please don't use ableist in this server.
ight
!resources if u want to revise
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
thanks
if ctx.author.bot:
return ``` this isnt necessary, considering commands cant be invoked by bots in the first place. 
there is already a check
kk
as mentioned 1hour ago
how do i give jsk access to other ppl too?
i dont think you can afaik
ive read docs but i havent seen anything saying everybody can use it
but ive seen people do it
idk because jsk is only for bot owners
Make a check ig
no?
jsk takes the id from a owner kwarg or the application and makes it so the bot owner can only use it
maybe theres a new feature or something
is it disjsk or is it jsk?
whats disjsk?
!pypi disnake-jishaku
😳
you mean this?
wait so disnake has threads support (threads have been existing for like 10-30 days or something)
they have existed longer than that
what's the name for it 🤔
!d discord.TextChannel.threads
property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.
New in version 2.0.
thats cool
!d disnake.TextChannel.threads
property threads: List[disnake.threads.Thread]```
Returns all the threads that you can see.
New in version 2.0.
nice
a fork?
Dpy fork
!pypi disnake
an active discord.py fork since discord.py ain't getting maintained 😭
ive been using it for 2 days 😭
2 days
ive been on it for maybe 2months
i love disnakes buttons tho
💀
lmao
!d disnake.ui.button
disnake.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`disnake.ui.View`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View "disnake.ui.View"), the [`disnake.ui.Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") being pressed and the [`disnake.MessageInteraction`](https://docs.disnake.dev/en/latest/api.html#disnake.MessageInteraction "disnake.MessageInteraction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
whats new
!d disnake.ui.View
class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
oh fuck there's timeouts which expires the buttons

damn
for what? raw api?
i forgor how to do basic python so does it go like class shitcordwtf(disnake.ui.View().timeout=180.0)
no
iirc you can do that in dpy also
you add it in super()
oh so super().__init__(timeout=...)
commands.Bot has a http attr which you can then do manual requests with (isnt documented)
Which one is better? ```py
if ctx.invoked_subcommand is None:
if not ctx.invoked_subcommand:
both do the same thing x]
first
class A(disnake.ui.View):
def __init__(self):
super().__init__(timeout=int)
Why that?
of course i was right 😎
checking for a type is always better
you never are
x[
wait if not ctx.invoked_subcommand checks if it's false
I see
!e
d = None
if not d:
print("lol")
else:
print("bru")
@shadow wraith :white_check_mark: Your eval job has completed with return code 0.
lol
nvm it does check if its none or false ig
Good to know, thx
commands.check
how would i use that with jsk..?
i dont think you can
afaik the only way for more people to use it is to add more ids in the owner kwarg in the bot constructor
that'll work?
i think so yes
Not to sure of jsk
but i suggest you trust them as jsk can run anything on your local computer afaik
a check for the Jishaku cog?
just get_cog("Jishaku") and .add_check
doesnt jsk run the code given in your local computer?
It's Cog.cog_check sorry
ah ok
!d discord.ext.commands.Cog.cog_check
cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.
This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
wait how would i pass the check?
what's the difference between py print(member_object.name) and py print(member_object.display_name)?
display_name will give the members nickname if they have one, if they dont, dpy will give their name
alr
so, if i want to give the name and discriminator then member.name is the way to go?
yeah
It's similar to how you make a custom help command you don't pass a check there ```py
class MyCog(Cog):
async def cog_check(self , ctx):
#stuff
In short , the function is the check itself
no that only sends the name without the discriminator
so, how would i send the name and discriminator?
str(member) , or member.name+"#"+member.descriminator
str(member) is the easiest way imho
just string the member as said
alr
y?
how do you check if a message is sent in a channel using for loop
cant tell rn
You don't need a loop for that
You can compare the ID of the channel the message is sent in to the ID of the channel you want to check against
using a simple if statement
no im trying to do something like:
for message in channel:
await message.add_reaction("emoji")
😳
I assume they were only giving pseudocode
why the async?
Pretty sure channel.history() is a generator
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
If you just want a list you can do .flatten() on it
It still would need to be awaited
async def suggest(ctx, *, query):
embed = discord.Embed(
color=0xff0000,
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}")
if "!suggest + your suggestion here." not in ctx.channel.topic:
return
embed.set_thumbnail(url=ctx.author.avatar_url)
channel = bot.get_channel(924998519432036393)
msg = await channel.send(embed=embed)
await msg.add_reaction("")
await msg.add_reaction("")
await ctx.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```
works but doesnt add reaction and send the confirmaton message
Pretty sure you need to get emoji object to provide as an argument to add_reaction, lemme check
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Nah that works too
Seems like it doesn't
hm
if your using vsc you can just copy paste the emoji lol
and what about the confirmation it doesnt work ethier
Unicode emoji
He's using guild emoji
ah my bad
``` that doesnt work too
async def suggest(ctx, *, query):
embed = disnake.Embed(
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
colour=0x4e5ece
)
channel = bot.get_channel(924998519432036393)
emoji1 = ""
emoji2 = ""
await channel.send(embed=embed)
await msg.add_reaction(emoji)
await msg.add_reaction(emoji1)
await msg.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```
like that mate?
Nono
oh
You didn't get the Emoji object
sorry idk how
I don't remember how properly but here's a method
discord.utils.get(ctx.guild.emojis, id=925060447974096937)```
hm
dk were to apply it
tbh
You didn't provide a required argument
One sec
ight
!d discord.Client.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
Oh thanks
await msg.add_reaction(bot.get_emoji(925060447974096937))```
@jagged root
kk
Please format your code
So fellas, I got me this bot that needs to build a report and transmit to an admin, problem is this report takes about 35 seconds to assemble… I cannot seem to figure out how to run the task without blocking the discord client and causing a timeout.
I have tried acyncio.loop and all but it only ends in a runtime error
@bot.command()
async def suggest(ctx, *, query):
embed = disnake.Embed(
description=
f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
colour=0x4e5ece
)
channel = bot.get_channel(924998519432036393)
await channel.send(embed=embed)
await msg.add_reaction(bot.get_emoji(925060447974096937))
await msg.add_reaction(bot.get_emoji(925060541335085056))
await msg.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```
still doesnt work
oh
is there any other way to track every message sent in the channel and add a reaction to it other than receiving the history, im not gonna get blocked by discord api :[
on_message event?
!d discord.Guild.roles
property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
Nice
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
🤔 i guess so, example?
@bot.listen('on_message')
async def message_listener(m):
#do_stuff```
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
I mean your bot already tracks messages
messages are appended into the internal message cache.
!d discord.Client.cached_messages
property cached_messages: Sequence[Message]```
Read-only list of messages the connected client has cached.
New in version 1.1.
You can process those 👌
!d disnake.ext.commands.Bot.cached_messages
property cached_messages: Sequence[Message]```
Read-only list of messages the connected client has cached.
New in version 1.1.
why?
doesn't getting the history of a channel send a request to discord api
i understand but wtf i need help is how i would get every message in a specific channel
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
limit=699999
Nvm can someone tell me the endpoint to fetch user details with required headers
does that send a request to discord API
Can't
if you try reading history
why not?
Phone not verified
is there a way you can get a timestamp accurate to the second instead of saying "in a few seconds" when its 30 seconds
verify it
not my problem, ask in dpy server then
loads of developers there
They probably won’t say anything there either
It's not a dpy related question
dpy has a general channel you know..?
There’s two different discord api servers you can go to. The unofficial and official.
It's a discord bot and python related question and looks like this channel was made for that
It does.
@boreal ravine
i think the request bigger the more history wants to be readed
every method in discord.py sends a request doesnt it? except cached stuff
and that method is not cached?
is there a way you can get a timestamp accurate to the second instead of saying "in a few seconds" when its 30 seconds
no your message cache is only as old as your bots lifetime.
well i have no __pycache__ folder so ¯_(ツ)_/¯
Probably yes
ur question wasn't discord-bots related at all, you were asking about the endpoint to fetch user details, you can either ask in the official/unofficial api server, or you can go read ddocs https://discord.com/developers/docs/resources/user#get-user
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
api/v8/users not sure about headers tho.
A bot token for the headers
It's directly related to discord
hmm i just looked at the docs but there is only <t:unixstamp:R> which gives "in a few seconds"
is there a different way?
stop making your own rules man
^
Just edit the message again and again
will you get ratelimited tho?
If someone asks you the same question but with dpy instead it suddenly relates to bots?
yes
depends on the context
Very dumb logic of yours
¯\_(ツ)_/¯
Just cuz I am asking it from, raw api doesn't change the aim
So to re-elaborate. You could theoretically get a channels message history yourself. But it’s unlikely it will be all of them. Since your bots internal message cache is only as old as your bots lifetime and it also has a limit too. So realistically you would have to make a api call either way.
Ofc u will
Hey I have a problem with this code
Hey @lusty heron!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Can someone check this code
It gives me this error
and say the error is "line 70, in update_status
users(user)[mode] = change
TypeError: 'dict' object is not callable"
https://pastebin.com/WiBPgyRk will get you all the history you want, key is to stash it someplace.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The syntax is invalid
user must be a key
And should be put in square brackets
did u mean users[user]
() is function
Yes
or a class
Hmm?
It worked?
One sec
Mhm
thats what she said
Why
found the answer to my original question: https://stackoverflow.com/questions/53587063/using-subprocess-to-avoid-long-running-task-from-disconnecting-discord-py-bot
or he, 😉
I changed that to status = users["status"]
Umm..... where did the user key go?
that would be wrong i guess
Umm...m
Thats where the error was
So....you basically removed the erroring code
Ingenious
What
coughs
It should be
status = users[user]["status"]
Oh ok thnx
@slate swanor it... happy?
spoonfeeder
oof
Hmm, yeah
why when i add embed.set_thumbnail(url=ctx.author.avatar_url) to my code it says AttributeError: 'Member' object has no attribute 'avatar_url'
please help
Interesting
Try adding a message attr after ctx
didnt understand
https://paste.pythondiscord.com/loridaruji.py
Hi! I have this keyerror in my code:
users[user][mode] = change
KeyError: <Member id=703671503954378782 name='down bad' discriminator='8487' bot=False nick='down christmas :snowman:' guild=<Guild id=897866866557603890 name='LateNight' shard_id=None chunked=False member_count=112>>```
You're on dpy 2.0 or 1.7.3?
ok 1.7.3
Try doing
ctx.message.author
okay
embed.set_thumbnail(url=ctx.message.author.avatar_url) like that?
same error
@olive osprey@lusty heronwhy u change account and ask same Q?
hes trying to be sneaky ofc
That was my friend, but he went to sleep. I've tried to find someone on stackoverflow to help me, but they didn't find a solution aswell.
^atleast not yet
@slate swan
still have to do 300functions😠😔
Interesting, ask @slate swan
@slate swan
why me
xd
why when i add embed.set_thumbnail(url=ctx.author.avatar_url) to my code it says AttributeError: 'Member' object has no attribute 'avatar_url'
F
see caeden is here
!d disnake.Member.avatar.url || ctx.author.avatar.url
No documentation found for the requested symbol.
this is what it is ^
hes smarter than me
but its not documented
That's not applicable for 1.7.3
due to the error he clearly isnt 1.7.3
i am
have to do 300 more functions bye guys
[[package]]
name = "discord.py"
version = "1.7.3"
description = "A Python wrapper for the Discord API"
category = "main"
optional = false
python-versions = ">=3.5.3"

should i update it?
ok
preferably
worked!!
it is
without updating?
i use disnake
yep
Pycord is way better imo but yea
why tf did you say discord.py 1.7 if you use disnake x.x
i was right either way but still
xd
everyone here uses disnake
pycord isnt that great imo
you're in the wrong place
Its not dead, it will remain in our hearts, respect for danny lmao
gone but not forgotten
Ofc
soon will
Someone here was going to complete their 300 funcs
shhhh
smh give me a break ive already done 1000 no joke😠😔
Lol, what're you making?
sad moment
cant tell rn
project is already at line 1945 im still missing 300funcs
Uh um....its alright
how many commands does your bot have
3
you gonna flex your 150+ commadns?
Like 10 or smth
230 ;)
😠
aero bot moment
your help command is seggsy tho👀
Just an API wrapper, nothing much
How do I get the number of commands in a cog?
ignore the temporary emojis
i think i have covid
no i havent done one yet
docs, crime and trivia are temp
!d disnake.ext.commands.Cog.walk_commands
for ... in walk_commands()```
An iterator that recursively walks through this cog’s commands and subcommands.
I’m pretty sure i have covid
Uh fine
havent done my api wrapper because..................
Cuz my cough
lazy
I should switch from discord.py to disnake
Lemme guess, you are on your periods?
Hi. Iv'e heard a lot of comments that json isnt a good database to use if you are planning to have a bot in many servers, are there any other good and easy-to-use options?
@slate swan https://github.com/Okimii/Pybot/blob/main/Pybot.py#L90 embed4 my dude you know you can call them embed
Pybot.py line 90
embed4 = disnake.Embed(```
im a male
Lol my bad
why you stalking me😳
LMFAO, is it because he had too many ...........
😂
Yeah
aiosqlite but you need to learn the syntax when retrieving data. there are cheatsheets though
ill take a look at it, thank you
https://github.com/CaedenPH/JesterBot/tree/main/cogs/Levels.py this has some good examples with aiosqlitw
jesterbot is a discord-bot coded in discord.py with over 230 commands and 27 cogs. - JesterBot/Levels.py at main · CaedenPH/JesterBot
!pypi aiosqlite
How would I switch from discord.py to disnake
the fat ad
not really
Self advert
just change the word discord to disnake and your done
Is that all?
yes
or import disnake as discord
ty
Thought there would be a lot more to do
just some helpful material - im not getting paid or anything
cough i do appreciate stars though 😳
you that broke you need donations?
ill donate one
i love github star donations <3
if you star pybot ;))
deal
deal
🤝
nods
🕵️♂️
you can make pull requests
How to send a msg when someone has boosted a server
Ask @slate swan
let me finish my 300 functions😭
Lolll
havent even started its been 10 hours😔
Annoying you is fun, I love it
😠
i did import disnake as discord and i got:
Traceback (most recent call last):
File "main.py", line 1, in <module>
Traceback (most recent call last):
File "main.py", line 50, in <module>
bot = commands.Bot(command_prefix='$', intents=discord.Intents.all())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in __init__
super().__init__(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in __init__
super().__init__(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in __init__
self._connection = self._get_state(**options)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/state.py", line 152, in __init__
raise TypeError('intents parameter must be Intent not %r' % type(intents))
TypeError: intents parameter must be Intent not <class 'disnake.flags.Intents'>
TypeError: intents parameter must be Intent not <class 'disnake.flags.Intents'>
and why😭
oh
Such jokes are not to be made
i did not realise
just search and replace
Utilize
on_member_update
and check if the servers booster role is in the after
You can uninstall discord.py tho
i mean yes its recommended
but it wont do anything
Uninstalling and using it in the as discord will prevent errors
If I’m making a help command by subclassing it, how would I sort it by cogs? Or is it harder to sort by cogs?
dont ping me for something i know about smh
its just as any cog?
Sorry, lovely okimii
why subclass when you can make the most sexy help command in the fucking world + have incredibly neat code https://github.com/CaedenPH/JesterBot/tree/main/cogs/helpcommand.py
jesterbot is a discord-bot coded in discord.py with over 230 commands and 27 cogs. - JesterBot/helpcommand.py at main · CaedenPH/JesterBot
i really need to start my functions😔
FAT AD
;)
he aint wrong tho ;))
Eh?
Caeden is smart
not in a good way
hes loves his help commands
like to much
Marriage when?
i think jan4
im not sure
Its alright
he didnt invite me smh
😔
I’m still confused
about?
!ot
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
get to topic ;))
What are you sorting by?
About this
coughs
exactly what?
@outer violet this may help https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96
not like i subclass help commands,just make a new command named help🏃
jesterbot is a discord-bot coded in discord.py with over 230 commands and 27 cogs. - JesterBot/helpcommand.py at main · CaedenPH/JesterBot
Yeah I’m following that but it doesn’t show how to sort by cogs
how can you chat bad to this shit
caeden we get it 😭
@commands.command(
aliases=['h', 'commands', 'cmd', 'command', '?', 'helpme', 'helpcommand', 'cmds']
)
async def help(self, ctx: Context, command=None) -> None:
if not command:
embed = await self.utils.main_help_embed(ctx)
return await ctx.send(embed=embed, view=DropdownView(self.data, ctx, self.utils))
cmd = self.bot.get_command(command)
if cmd:
embed = await self.utils.specific_command(cmd, ctx)
return await ctx.send(embed=embed)
cog = await self.utils.get_cog_from_str(command)
if cog:
embed = await self.utils.specific_cog(cog, ctx)
return await ctx.send(embed=embed)
embed = await self.utils.no_command(ctx)
return await ctx.send(embed=embed)
MY ENTIRE HELP COMMMAND
Lol same
FUCKING AMAZING
to lazy tbh
Caeden speaks of clean code but then the first thing I see when I open his shit is a wildcard import
he did what now?
because im importing like 15 emojis from a file i made x.x
caeden did you really did a wildcard import smh
Cant be more true
it is😔
there is nothing wrong with wildcard imports if you know what you're importing and you use it all and made the file
!pep 8
and you have a json file for prefixes 
smh
what is the easiest way to create a button?
subclass view
without classes?
haha no
like, a package or something
no such thing
uh, yes, yes there is.
there’s discord-components or whatever that garbage is called
if i am able to, i would like to avoid working with Classes i just hate it
dont
view = disnake.ui.View()
view.add_item(
disnake.ui.Button(
...
)
)```
without subclassing
what's the package?
i thought you were gonna ad a repo of yours
nah i dont do shit like tha

^
^
^
i meant i dont do shit like this
oh
who does it like that tbh
i just subclass view like a normal person
!pypi discord-components
Yikes
^^^ if you wants buttons without views
Is this the package that requires a wait_for
does it really?
I’m not here to judge, I’m here to give them what they want.
Nextcord does the same thing I heard
They completely removed views.
Ok it is that's a yikes
That means you are required to make listeners for every button you have and you cannot concurrently in the same function wait for two different button presses
TypeError: on_connect() missing 1 required positional argument: 'message'
Not to mention if you wanted the button to be able to be pressed any number of times you would need to spawn that many Futures
dang
good thing i dont use it
@client.event
async def on_connect(message):
ctypes.windll.kernel32.SetConsoleTitleW("Anti AFK • Ready as {}".format(client.user))
print('Logged in as: {}'.format(client.user))
TypeError: on_connect() missing 1 required positional argument: 'message'
My eyes
.format
why
Yeah we still use format funcs
ik but an f string is a thing
Outcomes of a youtube tutorial
!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.
freecodecamp?
Ew, maybe
lmao
@client.event
async def on_connect(message):
ctypes.windll.kernel32.SetConsoleTitleW(f"Anti AFK • Ready as {client.user}")
print(f'Logged in as {client.user}')
TypeError: on_connect() missing 1 required positional argument: 'message'
better?
!d discord.on_connect
discord.on_connect()```
Called when the client has successfully connected to Discord. This is not the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") for that.
The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") also apply.


