#discord-bots
1 messages · Page 1037 of 1
bro thats not an excuse
Said again, that doesn't matter
Lets keep it civil and maybe move on
!rule 5 still applies for educational reasons
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
you can only say that when it actually shows you something and you learn from it
At this point, it seems like it isn't worth arguing over further
If we're not going to help, we're not going to help. If you don't want to help, move on. If you want help, find it somewhere else. Easy as that, let's move on
ok, let's change the topic
my head😭
hows ur skiing going bro
bro can we stop?
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
.topic
I can't say it contains any :(
nsfw

I uh.. don't know if that's unique
hey mr @sick birch
how old r u if u don't mind me asking
I'm 17
old
young
damn then i'm ancient
😭
shit

keep it on topic tho
um?
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
alr i'm gonna go to stack overflow for help
hi grandpa
It's been awhile since I've used discord.py, what fork should I be using?
I think a lot of people here use disnake
why use a fork?
I heard that discord.py was discontinued ???
not anymore
oh
well, there are still reasons to use a fork
what are those reasons?
the application commands implementation in Discord.py is not too easy
is everything changed? in forks or is some what the same as discord.py?
if I have to learn a whole new module again to have a discord bot, I'll stick with discord.js
well there's a lot of changes
damn
alrighty, welp I guess I'm going to stick with JavaScript...
hmm
Questions about cogs?
I want to add a Anti-alts cog to my bot, if a user activates it, will it be global or only for that server?
If its global how could i make it Server-sided aka Only for that server? Without saving the server ID's or something else?
You can define cog_check within the cog and do something with enabling and disabling. Just think of a cog like doing bot.add_command(…) for commands in the cog. It will be global
!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").
what exactly are you stuck on
nevermind I got it didn't follow the tutorial
how to make it so that for when the channel was created, for a certain role set permissions speak = False, send_messages = False?
create_text_channel has an overwrites kwarg where you can pass in the overwrite of the channel and the member/role
!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...
What is the best way to see if the bot is connected to a voice channel in a given server?
!d discord.Guild.voice_client
property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
or, discord.Guild.me.voice
ooh, so I can store a reference to the guild and any time get the voice client?
Awesome 😄
Thank you! Works perfectly!
How do I properly call an async.await() within a synchronous function? loop.create_task() is executing it but not awaiting the result, how do I get that behavior?
why would you need to call it within a synchronous function
you wouldn't be able to await it in a non blocking way
I want to wait before retrying in an error handling done_callback
which done_callback can't be an asynchronous function per my recollection
unless you can pass a coroutine as a done callback?
for what method?
an asynchronous task
👀
I have a done callback which attaches to my asynchronous task
and I was under the impression that the done callback had to be synchronous, but I might be mistaken in that belief
What lib
You could probably do, ```py
def done_calback(...) -> None:
asyncio.get_running_loop().create_task(async_done_callback(...))
I'll give it a try
Wait, you're trying to await the result right?
well yes and no, I want it to wait until the normally awaited sleep finishes before completing the done_callback
yeah
wait 2s first time and 2**n each repetition
but if I just do create_task on the sleep it recurses outside the bigint handler within seconds as you'd expect lol
Ok, you'll need some synchronisation. I'll send an example of what you could do
your idea with the sync layer on the outside and the async on the inside worked
thanks 🙂
!e ```py
import asyncio
async def wait_for_event(event: asyncio.Event) -> None:
await event.wait() # <- Wait for event to be set
print("Event set.")
async def main() -> None:
event = asyncio.Event()
asyncio.create_task(wait_for_event(event))
await asyncio.sleep(1)
event.set()
asyncio.run(main())
@wary crystal :white_check_mark: Your eval job has completed with return code 0.
Event set.
Ah, cool. Use that one then instead of events
Yeah, it'll work fine for me and I don't mind the minor refactor
Thanks!
already done refactoring, quite an easy process
and now it'll work 😄
What are you creating specifically? Care to share
you need to write some code after the @bot.command
a function to be specific
How do I make a listener for DMs and add a response when someone DMs in d.py
24/7 error handled loops for various features like music player and word generator
How can I await the completion of voice_client.play() and only proceed when it hits the after state?
within async methods
it is playing the song but isn't waiting so going back through my logic it is constantly getting exception that it is already playing
it is presently hitting the done callback continuously rather than awaiting the after block to be hit
whats the asyncio.Event class for btw?
!d asyncio.Event
class asyncio.Event```
An event object. Not thread-safe.
An asyncio event can be used to notify multiple asyncio tasks
that some event has happened...
Synchronisation. It's kind of like your locks.
Your tasks, coroutines, whatever, will be awaiting for the event. via Event.wait(). When the event get's set with Event.set it'll continue after the await.
Any ideas on my above question?
ah ic
Are you adding the callback to VoiceClient.play(..., after=done_callback)?
I didn't do that but I suppose I could try that
I would suggest that then. Because after get's called when the AudioPlayer is done playing
It means that the youtube_dl package you are trying to import is not being found correctly, however, I am quite certain that assistance with youtube players is not permitted per the rules
I'll have to try to think about how to structure it, since the voice_done_callback was intended as an error handler but if I call it in the after it can't handle errors before that
You could try keeping your current implementation. But add a simple check to the callback. ```py
def callback(...) -> None:
if player.is_playing():
return
# Your implementation
Keep in mind, if your callback was not waiting for it to finish. Then this is pretty un-efficient. But it's a temporary fix
it will have to hit that loop quite frequently, ideally it will only hit the done callback when it finishes
and if I have an error handler in there it will delay exponentially so when the song playing ends it might be waiting 10 minutes by that time
flow control is such a tricky thing in async
To make sure, the callback just plays the song again, or?
And it's only done when there is an error raised?
the donecallback creates the next play task, yes, and also handles any errors and sends them to my sentry instance
it's not in a command at that point
it is in a task
command spawns the task, tasks spawn further tasks barrel of monkeys style, one attaching the next
I'm going to try while voice_client.is_playing having it sleep, it's not good but it's better than just running infinitely every .0001ms lol
Ahhh, you can infact do the after thing I mentioned. It takes a parameter which would be any errors
pip install youtube_dl
Like so, play(..., after=lambda error: print(error))
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
but the issue is that my structure is such that I save the tasks to a Server Object so they can be cancelled at will, that's a little more messy to call from after
since the done_callback needs to be bound to the task itself
Can you show me the code? It's a little hard to visualise this
I can screenshare over voice in about 10 mins if acceptable?\
having dinner in a moment
I can show you the application structure and implementation
I am not in the position right now to hop into a voice call. Do you have a GitHub repository or something alike?
Not a public one presently
All good, I would say try taking a poke at it again yourself with some of the ideas we dicussed. Perhaps you'll find a good way to do this. If not you are always welcome to ping me or something later
hey guys, I want to send my plotly graph to discord, do you know how I can do this?
the code literally hasnt changed
what gives?
the other pattern works fine
(i only have 2 patterns at the moment, havent received links for the rest yet)
quick question how do i made this thing into python?
var args = message.content.substring(prefix.length).split(" ")
Hello, I want to develop a python whatsapp bot which every day at a certain time it gives a message to a whatsapp group
vars = message.content[len(prefix):].split()
is that possible? I know how to send automatic messages with pyautogui but in order to send them I have to execute the program each time, I want to avoid that so I dont have to be executing the same file time
ty
taxmachine, are you doing that for a command in on_message event?
yes
you would like using discord.py's inbuilt command handler instead!
gimme a moment
idk im new to python
i just wanna remake my bot in python
oop
here
i wanna remake smth like that
see this example, you can make commands easily using commands.Bot
like i dont want annoying ifelse but switch/case(match/case) instead
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command()
async def ping(context):
await context.send("pong")
bot.run("token")
``` quite simpler
ahhh
tysm
for taking args you can simply add an argument to the command function
async def command(context, my_argument):
...
the non privileged ones are enabled by default
if my bot requires admin do i need intents?
if you are on the PyPi version ( installed using pip) message content is enabled by default too
Yes, permissions & intents are two different things
You still might need to enable message content intent in the developer portal
Don’t actually know
yeah sure
same thing with discord.js@12
@cyan raptor is annoying as hell 
wait not the ping
bruhbruh
im sorry i didnt meant that
mhm, ill recommend to install discord.py from git, it has components and app commands too ( along with some breaking changes) , you would have to shift to that later so why not do it rn
git+link of the repo in the requirements.txt right?
yeah
b
oh, you installed the git version right?
ye
go according to this example then.
i did
and jesus it take so long to connect
passed the intents?
Not sure if it's the same with djs, but discord.py will dispatch READY when caching is populated, therefor more guilds == longer startup times
nvm it works
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(..., intents=intents)
``` this part to be specifc
mhm
Well, the startup times is with all libraries basically, unless you have certain cache flags
But discord.py will defer dispatching READY until caching is done via checking asyncio.Events'
is there something like nodemon, so that when i save the file it restarts it ?
or maybe its built-in with python
are you using vscode? there are many extensions
yes but my hard drive is full 💀
Perfect excuse for some spring cleaning
garuda
Ah
arch 😩
yes thats why
i tried kubuntu a couple months ago
wasnt that bad but it was missing something
i fresh installed kali yesterday, without any penetration tools
and it looks so emptyyyyyy
yeah
did you tried remnux?
Kali is not bad, but the community has a bad rep
Tend to avoid it just because of that kek
my wsl terminal is kali
Speaking of fresh installs, started yesterday a new arch install, 600 some odd packges using Xmonad + Xmobar
Config is still in the works so I just got a black terminal right now and a buggy bar
@commands.Cog.listener()
async def on_message_edit(self,before,after):
if not after.author.bot:
if before.content != after.content:
embed=nextcord.Embed(title="Message edit",description=f"Edit by {after.author.mention}", color=0xfd9fa1, timestamp=datetime.utcnow())
fields=[("Before",before.content,False),("After",after.content,False)]
for name, value, inline in fields:
embed.add_field(name=name,value=value,inline=inline)
await self.bot.get_channel(933978399280599080).send (embed=embed)
```can someone help me with this?
if before.content != after.content: wasnt satisfied and you tried to send that embed
o tyy
how do i get a list of the channels?
there's context arg but idk really much ;-;
you can use ctx.guild.text_channels
ok it worked ty
^, if you need all the channels and not text ones you can just do guild.channels
!d discord.Guild.channels
property channels```
A list of channels that belongs to this guild.
context.guild gives you a discord.Guild object with pretty much stuff related to a server
https://discordpy.readthedocs.io/en/master/api.html#discord.Guild <- , here's all of them
..
discord must small the code if the code is going out of the codeblock else it ruins all the indents also add a zoom
.
intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'
u can just do intents = discord.intents.all()
that intent is added in discord.py 2.0, the pip install.. version wont have it.
also i think it's intents.message
no
what does this mean when I get this error: {"message": "405: Method Not Allowed", "code": 0}
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages
which do not meet the following criteria:
• The message was sent by the client
• The message was sent in direct messages
• The message mentions the client...
show code + full traceback.
ok i''ll revisit heh
What's the new feature?

💀 i didnt saw it
i was chaing my mode to light
you see that only after enlightment ¯_(ツ)_/¯
so i found
^
i was felling sleepy in morning
lol
hm, i didnt sleep.
off topic though.
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
um..
hey folks, does anyone know of a good way of copying an image attachment from an on_message event and have a bot repost the attachment without that attachment after deleting the source message and not having the bot's image vanish after a day? I have no issue getting it to post the image, the image just kind of times out after about 24-48 hours, which makes sense since the object reference has been deleted. Im just having trouble thinking of a creative workaround though. Example in screenshot and code snippet below (img variable is just the attachment url form the original message):
if len(message.attachments) == 1:
embed=discord.Embed(description=body)
embed.set_image(url=f'{img}')
embed.set_author(name=message.author, url=message.author.display_avatar,
icon_url=message.author.display_avatar)
embed.set_footer(text=message.created_at)
#how can I delete the on_message event and repost the attachment without the attachment timing-out/disappearring within a day?
await message.delete()
msg = await message.channel.send(embed=embed)
await msg.create_thread(name=thread, auto_archive_duration = archive_time)```
save the image locally,
and send it with your embed again.
or just read it, and send it
!d discord.Attachment.read
await read(*, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the content of this attachment as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
New in version 1.1.
oh interesting, and by referencing it this way, the deletion of the object wouldnt be an issue since its referenced as a bytes object?
💀 maybe i'm dumb, you can just attachment.to_file() to get a discord.File object ans send it directly!
yea, even if you delete the source, it will stay.
thank you! reading the doc on attachment.to_file() but may just use read
as a data engineer this is one of the only things you could have done in here to hurt me lol
at least give it a primary key constraint 😉
you would have to convert it to a discord.File anyways, so using to_file would be better
oo, yeah!
Why though, just use BIG INT
yeah i realise that would be better
me who uses list var 😎
i just need the timestamp integer tho~
sometimes its good for calculations but in those cases just cast in your query
oops responded to the wrong thing
Hey everyone, new here. Been stuck on an issue with my bot for several hours now. I think it's more of a general python question but I would love some help if yall don't mind
yeah, i get what was the reply for
feel free to ask!
since you helped me with the API feel free to ask me SQL questions any time lol. I never do this type of development but am ex-faang data engineer so I can maybe help there
sureee, thanks a lot <3
I'll post a screenshot of the structure. But basically it's a nested dictionary with lists values, and when I update one it sets the value for keys outside of it's scope. I'll post the picture then elaborate a little more
Go right ahead
for role in allowed_roles:
if role not in DATA[guildID]['allowed_roles']:
DATA[guildID]['allowed_roles'].append(role)```I was doing it another way, but switch to this for more visibility. the allowed_roles vairable is a passed in list of roleIDs, and the guildID is passed in as well from message context
but even if I pass in one guildID it updates all instances of 'allowed_roles' keys in the dictionary
Why not save it as BIGINT?
for this, does it essentially just create a new unique discord url for the file or does it legit download to the host machine? I can test it in about 15 mins so dw about it if youre not sure
If you wanna use INT for IDs use aiosqlite3 
I realize the proxy_url part thats the part im wondering about though
.save() would save it on your device
.read() would store it in a cache
.to_file() would convert it to a discord.File directly
and all of them make requests to the proxy url/url to get the bytes and then get that data
whoa
ok so its a legit web file
thats awesome, thanks man. Server has >30k people for an event and didnt want to deal with that load lol
wait what is there no limit on INT with aiosqlite3?
here is literally right before the step and after the step. You can see in the watch all 3 keys have their value updated
Unsure but the last time I inserted an ID into a column that was an INT worked
use a list comp? its a bit faster than a for loop iirc
lemme try
yeah it works, my own bot uses INT for ids
That isn't my issue though. Appreciate it, but the issue is data being updated outside of the scope
use a bot variable
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
whenever you set bot.test again in this case, it'll change the value of it even if its outside the scope
and make sure to not over-write an attribute or a method of the Bot class
Then I would have to pass the bot or client across all my files right?
you mean cogs?
I don't think so
uh....?
or are you creating functions in other files and importing those functions into your main file or smth....
Kind of, I have a data access layer with all my sql execution, a services layer with all my data management (a middle man of sorts for the DA layer and my main) and then all my functionality that doesn't require being in the main. Data analytics and parsing
then I have my main which has the commands
hm, ic, then what you could do is.....um... Better if you could shift those to a class and define a self.bot globally, and when initialize the class, you can pass in your main bot variable into it
I dont see a better ideal way
Yeah I just have a config.py with my variables that I load the data into from the database on_ready. And just have that file imported. It was just a nice organized way originally of doing it
wait, so, the config.py, how are you using bot currently in it?
waits forever
@slate swan so this is the main variable I have and how it is structured. I update the data based on the bot events, tasks, and loops. The call functions in my svc.py file like AddOrUpdateUser(guildID, userID, message_count) and it updates that data object. Which is constantly writing any changes to the database every few minutes. If the bot crashes, when it restarts it can pull that data from the database back into this data object
lol sorry
im having a stroke trying to understand, and your main issue, seems quite unclear, but it would probably help someone else help you 😔
So actually the main issue is a python issue I think more than a bot.
If you look at these two picture, there are watches set up on the left. You can see the 3 keys in the dictionary that are Guild IDs. When I run the next line it updates all three keys at one time to have new values for the 'allowed_roles' key
embeds are still limited to one main image right?
Yes
ty. Wish Discord would allow more :/
you can have multiple embeds in same message though, if that may help...
How to install 2.0 on vsc?
pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)
if it says Error [WinError 2] the system find the file specified while executing command git version ERROR: cannot find command 'git' - do you have git installed in your PATH?
means that I don't have python 3.8?
you have to install git (https://git-scm.com/downloads)
from the website/link?
Yes.
What
lmao
Nextcord?
Nice lib name
💀
tf
tf
?
💀
would cogs be the correct tool to facilitate 2 on_message events?
Example:
bot checks user message content
if content contains x
bot replies to user
if bot reply contains y //this is now a different message which is why I ask
bot async awaits to delete own reply.
hey guys how i can set a role (permission) for a cmd ?
like for warn cmd that member have to have {time outmembers]
Name? 😏
Yes
You don't have this from me
||NYYXXII on twitch||
how to check discordpy version?
!d discord.ext.commands.Cog.listener you can make as many handlers of the same event as you want
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
thanks guys
you can use "pip freeze" to see all versions of all dependencies you have on your environment. You should see it in there
hey guys how i can set a role (permission) for a cmd ?
like for warn cmd that member have to have {time outmembers]
Do you have the code for the command?
yea i coded warn cmd
Did you restrict it's access?
wym
@client.command()
@commands.has_permissions(administrator=True)
async def clear(ctx):
await ctx.channel.purge(limit=15)``` Sample of one that is restricted to administrator permissions only
wait so are you asking how to make it time people out or how to require it to have certain permissions for users to use the command?
@slash.slash() async def iplookup(ctx, *, ipaddr: str = None, ip.Option(str, "Enter an IP adress")):
^ "(" was not closed
Why am I getting this error ?
how to resolve it.... 😓
idk wym my english lunguge is not soo good
i mean i wanna set a permission to only that memeber that have that permission can use cmd
@client.command()
@commands.has_any_role("Moderator", "Admin") #<------This line here
async def warn(ctx):
#some code to warn user````
Like this. Just add whatever role you want in there in place of Admin and Moderator
no i mean role permission not role name :/
oh ok, Let me take a look quickly
ok
anyone ?
kunnu I will take a look in a second
ok...
Ok like this
@client.command()
@commands.has_permissions(administrator=True) #<------This line here
async def warn(ctx):
#some code to warn user``` You can replace administrator with whatever permission you want. There is a list here: https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions under the section called Attributes. They need to be spelled exactly how they are on there
Ok sorry I haven't used the @ slash command before. What are you trying to do with that?
im tryna make an iplookup command alr...but i wanna turn it into a slash command....
Ok
i mean i made the cmd alr i wann turn it into slash cmd
have you made any other slash commands successfully?
I recommend using a modern library like disnake, nextcord or discord 2.0+
im using discord.py...
discord-slash-command library
Thats an extension library
discord-slash-commands and discord.py arent same ?
"discord-py-interactions is, in the simplest terms, a library extension that builds off of the currently existing discord.py API wrapper"
discord-slash-commands is an add on the discord.py
its not a part of discord.py
Addon to dpy 1.7.3*
hmm...ok
are you looking at this documentation? https://github.com/interactions-py/library/blob/stable/docs/quickstart.rst
ive seen it but it doesnt have anything related to slash commands
ooh sorry, it has slash commands
how to prefix bot status in python 2.0
Hey, I have a quick question about my bot. I'm currently making a bot for a third party, and when I'm done I have "transfer bot ownership" to them, how exactly do I do that? Just share the source code to them.... or something else?
pip uninstall discord.py
Should work
wdym?
Or just do pip show discord.py
>>> import discord
>>> discord.__version__
'2.0.0a'
💀
Yeah that too and they can just do what i suggested if they don't want to add code to a file and run it
Personally i like doing the command more rather than checking in code
i was trolling, but anyways...
I don't think you can do that
you either:
- transfer it to a team so both you and the third-party "own" it
- do what you said
You can't
They have to make a bot application
That seems good, but I don't know anything about teams, can you explain more?
what it
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
await it.
thx'
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
where status "idle"?
1 more thing, when I send a friend an invite, how do they accept it, like where does that notification come up?
In the persons emails
ah ok, thanks
Is this Disnake?
no, discord py
Huh
how to add the number of servers that have a bot to the status
len(bot.guilds)
{len(bot.guilds)}?
Sure
len(bot._connection.guilds) 
Show your code.
@bot.event
async def on_ready():
print("Kiff connected")
await bot.change_presence(status=discord.Status.idle, activity=discord.Game("k.help | {len(bot._connection.guilds)}"))```
!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.
Amazon web server
Replit or heroku
I put my code in replit
And it says an error when it is downloading the requiremnets
Wtf
vultr
?
Replit and heroku are very bad. If you try to use them at any sort of scale for your bot it won't work.
@minor totem explain? 
guild.owner
yes
it's a Member object
Is there any advantages/disadvantages in using celery instead of discord.ext.tasks? If i understand correctly built-in tasks wouldn't work if i have multiple instances of the bot running
the __repr__ of a user/member object is something like this: <User id = user.id name = user.name discriminator = user.discriminator bot = user.bot>
instead, the cast of string to a User/Member object returns his name and discriminator
hey
gu.owner is None bruh
use cogs
what do u want
I want to make a command that list out all server that my bot is in
And the owner also
do u have intents enabled
i didn't define member, but my ide thinks its defined
Intents?
yes
U mean in the developer portal?
!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.
like this and dev portal
?
Waitt im doing
Im using phone
So its very difficult to do stuff
And i dont find advanced setting in mobile discord
did u enabled intents on the dev portal
Send me portal link?
alr wait
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
go there
then goto bot menu then enable these
Oo i just enabled it
ok
Lemme try again
Yes and my bot is in 100 server now
And im 7 months away from 16
did u enabled guild intents
:/
and member
I enabled 3 of them
can u show
add intents.guild = True there
Ok
Alright fk mobile replit
..
Its doing random shit
I press next space and everything is messed up
lol
press ctrl + z
The True become TTTTTTTrueee
L
Im on mobile dude
works on mobile tho
...
Im using mobile keyboard
That is a no
can u show
sad
Screw mobile replit
u doesnt have
Always does shit and mess up everything
in my i have and it works
lol
anyone know whats this
@loud junco worked?
honestly i dunno, never developed a game bot 
..
Pretty sure its whenever creating a game it shows you how the presence on discord looks
#test
@bot.command()
async def test(ctx):
await ctx.send(
embed=discord.Embed(title="dfghjk"),
components=[
Button(style=ButtonStyle.green, label="Yes"),
Button(style=ButtonStyle.red, label="No")
]
)
response=await bot.wait_for("button_click")
if response.channel == ctx.channel:
if response.component.label == "Yes":
await response.respond(title="wow")
else:
await response.respond(
embed=discord.Embed(title="Not wow")
)```
wait_for requires more arguments
!d discord.ext.commands.Bot.wait_for
oh nvm they're good
There is nothing in the console?
Don't code on replit then
But it's working fine on pc
Guys im very tired but need to get this done before I go to bed - my apologies if Im slow. Im trying adjust my previously no-cog bot to use event listeners. Essentially the entire reason is because I need 2 on_message events and this is the best way to do it based on everything I've seen/heard. I've set up a test cog:
import discord
import os
from discord.ext import commands
intents = discord.Intents(messages=True, guilds=True, message_content = True )
class Example(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('Ready!')
print('Logged in as ---->', self.bot.user)
print('ID:', self.bot.user.id)
@commands.Cog.listener()
async def on_message(self, message):
print(message)
def setup(bot):
bot.add_cog(Example(bot))
```
But my main file is pretty damn big at the moment. Im just trying to verify that the files are linked hence the print function. Im having a hard time trying to figure out out to implement this into everything ive written. Most of my main file is just a massive on_message event:
```py
intents = discord.Intents(messages=True, guilds=True, message_content = True )
bot = discord.Client(intents=intents)
@bot.event
async def on_ready():
#ignore - for testing in console
print('Logged in as {0.user}'.format(bot))
@bot.event
async def on_message(message):
archive_time = 60 #in minutes: Value must be one of (1440, 60, 4320, 10080). FOR THREADS.
delete_time = 120 #SET DELETION TIMER IN SECONDS HERE
minute_val = round((delete_time/60))
etc....```
From my understanding, I would need to:
1. rename one of the on_message events in either cog or main
2. Wrap the entire on_message event in the main file in a cog class?
3. I probably shouldnt be defining the bot user in both right...
4. all bot events need to be command.cog.listener?
Im so lost right now, this is the first thing Ive ran into with the API that I feel like no amount of documentation has gotten it through my head.
-----------------------------
Unable able to load mod❌
Extension 'cogs.mod' raised an error: ValueError: source code string cannot contain null bytes``` https://github.com/Carberra/updated-discord.py-tutorial/blob/master/lib/cogs/mod.py i am trying to do this but this is the error i get
Official repo of the "Building a discord.py bot (2020)" series. - updated-discord.py-tutorial/mod.py at master · Carberra/updated-discord.py-tutorial
can u show the full error?
Hey, how do I add vote rewards to my bot. Can't seem to find any good tutorials 
nvm these are terrible questions, I just need some sleep. sorry about that
cogs are supported only with commands.Bot, discord.Client does not support cogs
You have a pc?
thats a relative import, the error u sent before is not related to that
run ur code and send the error
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\client\__init__.py", line 15, in <module>
from .db import db
ImportError: attempted relative import with no known parent package```
^
Try from db import db
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\db\db.py", line 2, in <module>
from sqlite3 import connect
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\sqlite3\__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
ValueError: source code string cannot contain null bytes```
from sqlite3 import connect
from apscheduler.triggers.cron import CronTrigger
DB_PATH = "./cogs/db/database.db"
BUILD_PATH = "./cogs/db/build.sqlite"
cxn = connect(DB_PATH, check_same_thread=False)
cur = cxn.cursor()
def with_commit(func):
def inner(*args, **kwargs):
func(*args, **kwargs)
commit()
return inner
@with_commit
def build():
if isfile(BUILD_PATH):
scriptexec(BUILD_PATH)
def commit():
cxn.commit()
def autosave(sched):
sched.add_job(commit, CronTrigger(second=0))
def close():
cxn.close()
def field(command, *values):
cur.execute(command, tuple(values))
if (fetch := cur.fetchone()) is not None:
return fetch[0]
def record(command, *values):
cur.execute(command, tuple(values))
return cur.fetchone()
def records(command, *values):
cur.execute(command, tuple(values))
return cur.fetchall()
def column(command, *values):
cur.execute(command, tuple(values))
return [item[0] for item in cur.fetchall()]
def execute(command, *values):
cur.execute(command, tuple(values))
def multiexec(command, valueset):
cur.executemany(command, valueset)
def scriptexec(path):
with open(path, "r", encoding="utf-8") as script:
cur.executescript(script.read())```
Hm
thats not the error u showed b4, anyways have a look at this https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
I dont get it
I am guessing its trying to connect to the sqlite
Guys, I am creating a command and in this command I want to add the mentioned people and the admins as well, my problem is as follows: when I mention the users in the command, it should create a room and add the 2 mentioned users and the admins, only that it just adds one person
Code: (Forget the spaces, in my original code there are none)
async def real1v1 (ctx, arg, product, *, stars):
embed = discord.Embed (title = f "New realistic 1v1 wager for {arg}", description = f "** Team 1: {product} vs Team 2: {stars} **", color = discord.Color.red ())
guild = ctx.guild
member = ctx.author
admin_role = get (guild.roles, name = "RoleTestAdmin")
overwrites = {
guild.default_role: discord.PermissionOverwrite (read_messages = False),
member: discord.PermissionOverwrite (read_messages = True),
admin_role: discord.PermissionOverwrite (read_messages = True)
}
channel = await guild.create_text_channel (f'Team1-Team2 ', overwrites = overwrites)
embed.set_footer (text = f "{ctx.guild.name}")
await ctx.send (embed = embed)```
Ya?
I thought you would use an IDE that's not online if you have a pc
But I don't have a wifi
And I'm not at home more than 15 hours a day
How the hell do you use replit then
The uptime monitor?
What
The 247 thing
Uptime robot
After u run it u don't need to open the site to keep it running
Oh forgot you're one of those
need some help please
Hello Powell @flint isle
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "<string>", line 40, in on_ready
NameError: name 'self' is not defined
Code?
@bot.event
async def on_ready(autopost=True, case_insensitive=True):
print(Fore.GREEN + 'Connected!' + Fore.WHITE)
print(Fore.GREEN + 'Bot is ready!' + Fore.WHITE)
print(Fore.CYAN + 'Waiting For Commands' + Fore.WHITE)
bot.get_guild(798726719573065749)
GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
channel = bot.get_channel(798726720181633047)
await channel.send('Bot Online!')
embed = disnake.Embed()
embed.title = f"**Online**"
embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n"
f"- Bot account: `{self.bot.user.name}`\n"
f'- Bot ID: `{self.bot.user.id}`\n'
f"- Guilds: `{len(self.bot.guilds):,}`\n"
f"- Users: `{len(list(self.bot.get_all_members()))}`\n"
f"- Project Repo Version: `{repo.version}`\n"
f"- Disnake Version: `{disnake.__version__}`\n"
embed.set_footer(text="Logging System")
await self.bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID).send(embed=embed)
You don't have self defined
Ah what do I define self as then
Why not use docstrings?
Just use bot
Hmm? Idk what that is
Are you in a class?
No
"""
docstring
"""
"""
Peepee
Poopoo
"""
!e
print(
"""lol
im a docstring
""")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | lol
002 | im a docstring
003 |
Bruh?
🏂
Not cool guys
Just use your bot variable
Ok
What did i do
I just realized why self was in it. The friend that gave me the code meant for it to be on a cog
GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
await bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID).send(embed=embed)
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
Also get_guild isn't a async
Since it just gets the guild from the bot's cache
Usually any method with get is just synchronous
Any api call is asynchronous
Ok
So should I do instead
GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
await location.send(embed=embed)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\db\db.py", line 2, in <module>
from sqlite3 import connect
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\sqlite3\__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
ValueError: source code string cannot contain null byte`s```
from sqlite3 import connect
from apscheduler.triggers.cron import CronTrigger
DB_PATH = "./cogs/db/database.db"
BUILD_PATH = "./cogs/db/build.sqlite"
cxn = connect(DB_PATH, check_same_thread=False)
cur = cxn.cursor()
def with_commit(func):
def inner(*args, **kwargs):
func(*args, **kwargs)
commit()
return inner
@with_commit
def build():
if isfile(BUILD_PATH):
scriptexec(BUILD_PATH)
def commit():
cxn.commit()
def autosave(sched):
sched.add_job(commit, CronTrigger(second=0))
def close():
cxn.close()
def field(command, *values):
cur.execute(command, tuple(values))
if (fetch := cur.fetchone()) is not None:
return fetch[0]
def record(command, *values):
cur.execute(command, tuple(values))
return cur.fetchone()
def records(command, *values):
cur.execute(command, tuple(values))
return cur.fetchall()
def column(command, *values):
cur.execute(command, tuple(values))
return [item[0] for item in cur.fetchall()]
def execute(command, *values):
cur.execute(command, tuple(values))
def multiexec(command, valueset):
cur.executemany(command, valueset)
def scriptexec(path):
with open(path, "r", encoding="utf-8") as script:
cur.executescript(script.read())```
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@jade tartan that will help us read it easier
I have done that
cant u see it
Three tickmarks?
ill just post it on !paste
Ok
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Cuz i literally did that
You did not
Would this work better?
It is clear you didn't
Top 3 Need to be on a line by themselves
That should work
K
Also you should ask that in #databases
Since it isn't related to discord bot
Ohh u mean it was i suppose to do it as all together like error and code combined?
both
No
Seperate
Just do this to your code then send it in #databases @jade tartan
ok

I dont know what you mean there
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Not what I meant but oh well
Open the secondary symbols
Yeah got this again
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
embed = disnake.Embed()
embed.title = f"**Online**"
embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n"
f"- Bot account: `{bot.user.name}`\n"
f'- Bot ID: `{bot.user.id}`\n'
f"- Guilds: `{len(bot.guilds):,}`\n"
f"- Users: `{len(list(bot.get_all_members()))}`\n"
# f"- Project Repo Version: `{repo.version}`\n"
f"- Disnake Version: `{disnake.__version__}`\n"
embed.set_footer(text="Logging System")
GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
await location.send(embed=embed)
# Add Cogs```
Show me your bot constructor
Hmm? Please define for my simple brain
The event?
How and where you defined bot
Ah
bot = commands.Bot(command_prefix="$")
ct = datetime.datetime.now()
guild_ids = []
print('Starting Bot')
print('Connecting to Discord API.')
print('Please Wait')
Also why do you have those kwargs in the arguments?
Hmm which ones
The guildid and channel ones?
Or the embed=embed
hi
the on_ready event
long time didnt chat here
Sup

Idk . Are they unnessary?
Got it from a guide when I started working on my bot a while ago
on_ready takes no arg smh
Yes
Lol I've had no issues til now. But I'll remove them
!d discord.on_ready
discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful
and the [`Client.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up...
Ah have the nonetype has not attribute error still
@Bot.event
async def on_ready():
"""Called when all the bot cache is ready"""
print("uwu im ready")
something like that
What's the """ for?
im explaining to you the function does
Docstring
that's a docstring
We said it before
Is it the same as using the # for notes?
Well yes but you don't have to manually add # at every line
Oh thanks that helps me
mhm but you can access it with func._doc_ or when you hover that function in your ide that text'll show
Back to this lovely error again lol
not quite
Ahh there is no hovering in my ide lol since it's pydroid on android
sounds painful
this ^^
It is a little but it works for me. I am looking at getting a laptop when I get my second paycheck
it can be used as one but its mainly used for the sphinx and other documentation like vscs which when you preview youll see the description but some people use it sometimes as well besides comments which they really dont do anything depending on your ide
It is
Do not buy a chromebook
It sucks absolute ass
hey hey👋
Omiki
What budget laptop is reccomended. I'm tempted to buy used and upgrade ram and had if nessary.
No, docsstrings help in giving a visual idea of what the function is for, and what arguments a function/class takes
You probably shouldn't ask me that
Oh
Never had a good one nor bought one myself
you literally just couldve said documentation 😭
I was actually force to buy this chromebook from my sister
Just get a computer that has good ram, fast processor, and plenty of storage. that’s all you need unless you plan on doing other stuff besides programming on it.
Umm
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "<string>", line 47, in on_ready
AttributeError: 'NoneType' object has no attribute 'get_channel'
embed = disnake.Embed()
embed.title = f"**Online**"
embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n"
f"- Bot account: `{bot.user.name}`\n"
f'- Bot ID: `{bot.user.id}`\n'
f"- Guilds: `{len(bot.guilds):,}`\n"
f"- Users: `{len(list(bot.get_all_members()))}`\n"
# f"- Project Repo Version: `{repo.version}`\n"
f"- Disnake Version: `{disnake.__version__}`\n"
embed.set_footer(text="Logging System")
GUILD_ID = '798726719573065749'
CHANNEL_ID = '798726720181633047'
location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
await location.send(embed=embed)
# Add Cogs```
She owned it and i was just using it for school then she just one day said "You own that now" to me and just took 5k from my money
and mostly dont use pycharm so you actually can use your ram
Oof
you do know with 5k you can easily buy a desktop with a 3090 right
If you have enough ram you should use pycharm(the superior ide)
🤮
How superior
Shrek
superior and takes 1gb of my ram🏂
What
@slate swan well 5k is worth roughly around 100$ to you
then my computer is worth 12 dollars to me
How much is your pc
1.2k 
doesnt mean im rich tho i worked for my money for about 2 years
Not a american equivelant of a laptop plastic play thing
1$ is 50 here
intents with capital I?
yep
!e ```py
print(50*100)
@supple thorn :white_check_mark: Your eval job has completed with return code 0.
5000
ok
its a class
Sadge
Yes, all public classes in d.py are capitalized
Yes that is what i want
What i will get
how is that private?
It isn't
How
edited 😳
How what?
👁️
@bot.command(name='server')
async def server(ctx):
number = 0
for gu in bot.guilds:
number += 1
print(f'{number}) {gu.name}: {gu.owner}')
```i did this
I just realized if i zip DuckDuck it's 103mb
some has username some is None huh
what was said before 👀
Any ideas on how to fix dis
Hope that doesn't freeze your bot when it gets big
i just use it now

im downloading blender :D
That froze my chromebook for a solid 25 minutes
Should do the below if you want faster results
print('\n'.join(['{i:,}. {g.name}: {g.owner}' for i, g in enumerate(bot.guilds)]))
lol i can feel ur pain
Tried to bake shit
Aren't chromebooks meant for schools?
what job is that
they have low RAM fwiw
Should of not tried that with a chromebook
I know
Yes that's why i hate it
i have no job
i just did chores for my family like cleaning cars and other stuff like yard work
gotta respect the hustle😳
I fixed my code. Apparently I passed the id's wrong and when it trys sending the embed i get
Starting Bot
Connecting to Discord API.
Please Wait
Loading Developer Features cog
[✓][Developer Features Cog] Loading Complete
Connected!
Bot is ready!
Waiting For Commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "<string>", line 48, in on_ready
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/abc.py", line 1504, in send
data = await state.http.send_message(
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/disnake/http.py", line 414, in request
raise Forbidden(response, data)
disnake.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
why is your bot getting only half tracebacks
Hmm? Idk what you mean
what are you doing in on_ready anyways
So it sends a online message to a bot status channel
the bot is missing permissions to send message
Omg I had embedded content disabled in the channel
I feel so dumb lol
Umm I'm only getting the first line
embed.title = f"**Online**"
embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n"
f"- Bot account: `{bot.user.name}`\n"
f'- Bot ID: `{bot.user.id}`\n'
f"- Guilds: `{len(bot.guilds):,}`\n"
f"- Users: `{len(list(bot.get_all_members()))}`\n"
# f"- Project Repo Version: `{repo.version}`\n"
f"- Disnake Version: `{disnake.__version__}`\n"
embed.set_footer(text="Logging System")```
how to make disnake button?
@slate swan
I fixed the formatting and now it works
embed = disnake.Embed()
embed.title = f"**Online**"
embed.description = f"[`{datetime.datetime.now().strftime('%b-%d-%Y`] @ [`%I:%M:%S')}`]\n\n" \
f"- Bot account: `{bot.user.name}`\n" \
f'- Bot ID: `{bot.user.id}`\n' \
f"- Guilds: `{len(bot.guilds):,}`\n" \
f"- Users: `{len(list(bot.get_all_members()))}`\n" \
# f"- Project Repo Version: `{repo.version}`\n"
f"- Disnake Version: `{disnake.__version__}`\n"
embed.set_footer(text="Logging System")
How can I get the ID of a person just by their name and disc? Example: pal#1337
but why so many formatted string
why not make them one
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
I think the main problem was
he has to convert the string to a member or user object first
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI...
Idk it's what a friend gave me. I will look I to thay tho
!d discord.Guild.get_member_named
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001”
or “Jake” will both do the lookup. However the former will give a more
precise result. Note that the discriminator must have all 4 digits
for this to work...
my bad
it's okay
gg idk how to use blender 💀
learn-
im tryin-
its easy-
BRUH
its my first time doing editing btw
blender is nice and easy, anyways ot
In what context
been long, since I used it, but their docs probably specify every bit
im just trying to make uv for ursina
well, ot
@slate swan ?
sure
yeah, you didn't ping me so I didn't see your message till now
!pip dblpy
^ use this
ty <3
im trying to make my discord bot send an embed when someone runs the "/message [json]" command with json looking like this:
{"title":"Title","description":"Description","author":{"name":"Name","icon_url":""},"color":5198940,"footer":{"text":"Footer"}}
heres the code:
if cembed:
json_object = json.loads(cembed)
title = json_object["title"]
description = json_object["description"]
name = json_object["name"]
icon_url = json_object["icon_url"]
color = json_object["color"]
footer = json_object["text"]
embed2 = nextcord.Embed(title=title, description=description, color=color)
embed.set_author(name=name, icon_url=icon_url)
embed.set_footer(text=footer)
await ctx.send(embed=embed2)
but when I try to do that this error comes:
'name'```
in the example json you sent there's no top-level key called "name"
there's author, under which there is name
Yo
Hey so in the event that my voice_client shows as not is_connected() during playing when it hits the after callback it throws an exception. How best do I handle this? What are the best methods available?
!d discord.Embed.from_dict does exactly what you need btw although the json format is probably different
classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") provided it is in the
format that Discord expects it to be in.
You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
Exception: Not connected to voice, message: Calling the after function failed.
guys i need help because this code get a error saying
oh boy
You don't close the parentheses for run() on line 95
@slate swan how do I add reactions? 😔 im lost
nvm , I found it, sorry
Oh hell keep_alive
How to get the membercount of only one server?
-partners
XY Server = 600 Members
YX Server = 523 Members
Message.add_reaction as usual
get the guild then get its member count
its actually a method for hikari.PartialMessage from which the Message class is derived
!d discord.Guild.member_count
property member_count```
Returns the member count if available.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and
accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified...
Guild.member_count looks like your best option
copy the code and paste here
instead of screenshooting tons of them
oh thank you very much
best trio: flask keep_alive and replit
learn ur basic before discord bot
if not u are going to suffer a lot
okay
ive never used keep alive
lol
i just handle the hbs myself
cuz u nvr use replit ig
it will make the bot run forever
this dude's bio
your bot can't ever run continuously on replit
whats hb
@slate swan and and, how do I change the permissions for a channel? 😔
LOL rate limit
ya
GuildChannel.edit takes a permission_overwrites kwarg
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
alright its guild = bot.get_guild(ur guild id)
bot.get_guild
its a method of the Bot class🏂
uh, so how do I specify the dictionary keys for like, I wanna remove the permissions for reactions for every role
or wait, edit_overwrite exists too, ic
overwrite = PermissionOverwrite(
type=PermissionOverwriteType.MEMBER,
allow=(
Permissions.VIEW_CHANNEL
| Permissions.READ_MESSAGE_HISTORY
| Permissions.SEND_MESSAGES
),
deny=(
Permissions.MANAGE_MESSAGES
| Permissions.SPEAK
),
)``` this is what i got in the docs, you may pass `Permissions.NONE` or simply `0` for the allow and deny to remove it
hm, ic, thanks
⭐overcomplicated library abstractions⭐
✨ you can simply pass the permissions integers too if you want it very basic ✨
harder to debug
⭐ no⭐
im aware, but someone found cleaner things overcomplicated
😔 it requires some id for the entity, what do I pass for this?
id kwarg in the PermissionOverwrite
the id of the entity you want to edit
I know-
but what do i pass in it 😔
ah ic
a snowflake
me who still doesnt understand 😭
snowflake is just an ID..
TypeError: 'PermissionOverwrite' object is not iterable
overwrite = hikari.PermissionOverwrite(id=channel.id, type=hikari.PermissionOverwriteType.MEMBER, deny=(hikari.Permissions.ADD_REACTIONS))
I'm probably doing something dumb
show more code \🗿 and full traceback
sure
you tried to iterate through a class thats not an iterable
so it doesnt have __iter__🏂
I want to get the Member count of two server and well... I can only say it somehow went wrong?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
get_guild returns None
most methods that are get_* can return an object or None
permission_overwrites should be a "list" of PermissionOverwrite
try bot.fetch_guild
just add a [] and you're cool
i would recommend you use getch or get the guild first
oops, you have to await it because it makes an api call
now this comes up
