#discord-bots
1 messages · Page 615 of 1
oh yeah he forgot to do that too
delete the image , it has your token ( in case you already didnt regen it)
thanks, just realized
🥲
regenerate your token
add
client = discord.Client
just below
import discord
also your indentation is still wrong... check the if statements
after fixing that, try running the bot then
Lmao
his name is a reference to the state of his code
how to get timezone of ctx.author using the pytz module?
i cant sem to fix the indentation
it keeps saying I have to use UTC
@slate swan I suggest learning the basic python syntax first....
how did i not see that...
👁️
where can i learn that?
jumping to the harder stuff = not recommended
just find a basic tutorial
corey shafer or smth
aight then, thanks for the help
explains things pretty good
please ffs
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I learnt from NeuralNine
Is there an on_member_connect_voice_channel event?
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
@lapis frigate this maybe
ok sorry
library?
What library are you using
what library first of all
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
!d discord.Interaction.user
The user or member that sent the interaction.
wot
need it for buttons, nothing speciial
Show me your bot variable
client
cool, cool but next time in #bot-commands 😉
one sec ill send code
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
intents = discord.Intents.default()
intents.members = True
prefix = 'z!'
client = commands.Bot(command_prefix='z!', intents=intents)
slash= SlashCommand(client,sync_commands=True)
@slash.slash(
name="test",
description="description"
)
async def test(ctx:SlashContext):
await ctx.send("it worked!!!")
client.run(token)
well I don't know this library so can't help, but afaik slash commands take ~1 hour to update globally so maybe it's that
again, not sure
that might be the problem
what does sync_commands do
cause it only works on 1 server
tbh idk 😂
smh
what im doing wrong?
hl = ctx.guild.channels
takeguild = discord.Guild.channels(list[hl])
await takeguild.set_permissions(ctx.guild.default_role, send_messages = False)
emb = discord.Embed(title = "Server Lockdown 🔒", description = f"**{ctx.guild.name}** is now locked.", color = discord.Color.red())
emb.add_field(name = "Message", value = message, inline = True)
emb.set_footer(text = f"Locked by {ctx.author}")
await ctx.channel.purge(limit = 1)
await ctx.guild.channels.send(embed = emb)
discord.Guild.channels is wrong
your not supposed to use the class
your supposed to use the object/instance of discord.Guild.channels
hm
Just do a for loop for the guilds' channels
alright
for channel in ctx.guild.text_channels:
...
since discord.Guild.text_channels returns a list your bot is gonna change every text channel till it's done
okay
hello, there is no recruitment or offers/asking for paid work of any kind on the server. please check #rules
thanks!
when I leave the channel in on_voice_state_update the code does not recognize that I was in the channel
this is my code:
async def on_voice_state_update(member, before, after):
if before.channel==None:
before_members=[]
else:
before_members=before.channel.members
if after.channel==None:
after_members=[]
else:
after_members=after.channel.members
print(before_members)
print(after_members)
print(before.channel)
print(after.channel)
if before_members!=after_members:
if member in before_members and member not in after_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} leave the voice")
elif member in after_members and member not in before_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} joined the voice")```
when i joined it's work
um hey, do you know how I could get a list of all the roles in a server?
hey u using the discord-py-interaction package that has the slash commands?
Consider docs
!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.
pip install discord-py-slash-command
yeah that one. i use this package with my bot and its works well
I saw many bots having ss command and it takes the screenshot of the url provided. I also wanna make a command like that. Can anyone tell me how should I start?
when inviting the bot, does it show create commands in a server?
one sec
and does it hav the use application commands perm enabled?
what happened to the this will allow bot to page?
Add the applications.command scope to the invite link
i did
Apparently not
Should appear before that message though
@simple surge go to the dc app portal, go to application, go to your bot, go to auth2, go to general and select applications.command to the scope
Not this
ok
when i tried to add your bot, it didnt show an allow bot to page
good, now wait for about an hour for the slash cmds to load up in the servers 
its only in around 34 servers it doesnt rlly matter
hmm well
If the bot wasn't invited with the applications.commands scope in these servers
It won't create any slash command
oh yeah
um so i got a problem, i want to convert time to second with this code :
and shown error TypeError: can't multiply sequence by non-int of type 'dict'
can anyone tellme where is the problem
act like they hav to invite it
time_dict = {"h": 3600, "s": 1, "m": 60, "d": 86400}
class TimeConverter(commands.Converter):
async def convert(self, ctx, argument):
args = argument.lower()
matches = re.findall(time_regex, args)
time = 0
for v, k in matches:
try:
time += time_dict[k]*float(v)
except KeyError:
raise commands.BadArgument(
"{} is an invalid time-key! h/m/s/d are valid!".format(k))
except ValueError:
raise commands.BadArgument("{} is not a number!".format(v))
return time```
this is from my bot's repo
well you cant spoonfeed code bro
also import re and asyncio and let me know if it works
but tq ill see
my bot is under the mit license so... 
idk that too hard to learn
can anyone tell me how this would be used
i think it will shown up all users on the server to the logs
oh um i mean how would it be used within the code
idk for how to use
when I leave the channel in on_voice_state_update the code does not recognize that I was in the channel
this is my code:
async def on_voice_state_update(member, before, after):
if before.channel==None:
before_members=[]
else:
before_members=before.channel.members
if after.channel==None:
after_members=[]
else:
after_members=after.channel.members
print(before_members)
print(after_members)
print(before.channel)
print(after.channel)
if before_members!=after_members:
if member in before_members and member not in after_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} leave the voice")
elif member in after_members and member not in before_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} joined the voice")```
when i joined it's work
how i can fix that?
Try adding a print statement at the top which will print anything random to see if the code is even getting executed
How to get the user status using discord.py? Not online or dnd. I am talking about text status
!d discord.Member.activity
property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
!d discord.CustomActivity
class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.
x == y Checks if two activities are equal.
x != y Checks if two activities are not equal.
hash(x) Returns the activity’s hash.
str(x) Returns the custom status text.
New in version 1.3.
Ok thanks
if ctx.channel.category != "category name":
return
why this if statement does not work?
the code is executed but before.channel.members is [] (None)
i want a command to be ran only under 1 category
Because u joined a new VC, so before.channel is None
!d discord.ext.commands.in_any_channel
!d discord.ext.commands.check
i can fix that?
@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
???
Is there a way to get the people who were? or not
!d discord.VoiceChannel.members
property members: List[Member]```
Returns all members that are currently inside this voice channel.
but it's None
U can use the after arg
but i'm not in the voice channel after
Ok so let's start from the starting... What do u want to achieve?
when member leave voice channel
Yea
but it's not working
that's working
yes
Okay
the code:
@client.event
async def on_voice_state_update(member, before, after):
if before.channel==None:
before_members=[]
else:
before_members=before.channel.members
if after.channel==None:
after_members=[]
else:
after_members=after.channel.members
print(before_members)
print(after_members)
print(before.channel)
print(after.channel)
if before_members!=after_members:
if member in before_members and member not in after_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} leave the voice")
elif member in after_members and member not in before_members:
channel=client.get_channel(889215576487120956)
await channel.send(f"{member.mention} joined the voice")```
if before.channel is None:
# The person just joined a new VC
return
# Your code when the person leave a VC
thanls
using dislash.py
@inter_client.slash_command(guild_ids=test_guilds, description="Button test")
async def button(inter):
row_of_buttons = ActionRow(Button(style=ButtonStyle.green, label="Yes", custom_id="green_button"),
Button(style=ButtonStyle.red, label="No", custom_id="red_button"))
await inter.send("Yes or No?", components=[row_of_buttons])
inter = await inter.wait_for_button_click()
button_text = inter.clicked_button.label
await inter.reply(f"oh you have chosen {button_text}")
error:
inter = await inter.wait_for_button_click()
AttributeError: 'SlashInteraction' object has no attribute 'wait_for_button_click'
@ me in response
thanks
But what if there was someone in the channel?
not exactly
U can do all that in the code after the if statement (:
Faster Than You @slate swan :D
me mobile
Same haha
fawk
ok thanks
?
unfair
Aw
!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)
Sorry, music bots against ToS :c
haha
that's not how wait_for works
pretty sure you meant wait_for("button_click")
No
dislash
row_of_buttons = ActionRow(Button(style=ButtonStyle.green, label="Yes", custom_id="green_button"),
Button(style=ButtonStyle.red, label="No", custom_id="red_button"))
WHYYYYYYYY 🥺
same thing
cuz I'm a different breed
and I'm probably gonna switch to djs
You should.
no
You should.
yes
Traitor 😭
yes
js syntax kinda frustrating tbh
no syntax
I use djs for my bot's dashboard. I learnt it for only the purpose of getting the bot's guilds and other things, and it's actually great and easy.
js is just syntaxless
Lmao
wha
If you are very used to Python, then yes.
Anyways let's leave this. It's OT
sure
he knew that
bot.user.username*
i hope something adds function decorators to it at some point
inter = await inter.wait_for("green_button")
button_text = inter.clicked_button.label
await inter.reply(f"great u slected {button_text}")
inter = await inter.wait_for("red_button")
button_text = inter.clicked_button.label
await inter.reply(f"great u slected {button_text}")
now?
no?
Even this, you're bad at it. @maiden fable
No documentation found for the requested symbol.
huh
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
What’s wrong with ffmpeg. It doesn’t do anything wrong like yt-dl. It’s just an audio transcoder
This is there tho
yep
It still downloads audios from YT bro
because thats the docs
Ok I'm bad.
.user returns discord.User
hah
Yea
me like: 😹
True
it scrapes the webpage doesnt check like typehints and stuff of the actual code
I though that’s what YouTube-dl does tho. You use the two in tandem because they do seperate things. yt-dl downloads and ffmpeg for audio.
But YT is the common source for both of them haha
Where else do u get the audio from
I mean some people use ffmpeg "legally". I’ve had a friend use it for a school project. Just because its commonly used with yt-dl doesn’t mean the software itself is bad.
you can use ffmpeg when not downloading music from youtube nor spotify
I use ffmpeg with gtts to make tts commands in voice channels
Never said it's itself is bad, but when used with a discord music bot, the use case becomes illegal
Ah I see. I misunderstood your sentence then. Mb.
what's this?
Ignore that, mb
use category.name
if ctx.category.name !=
It's easier, ya know
They never said anything, so I thought they knew more than just if statements 🤷♂️
It's a basic judgement if u r using a lib like dpy, as long as the person doesn't himself tells the true thing
I was one of them
This one ^^^
I still am
🤣 I started dpy when I didn't know what were functions used for and there's a thing like decos or classes and objects
how did you learn about them
stackoverflow
Random articles. Read on multiple websites, asked from people in dpy server and I somewhat understood it. Then I would read help channels, see a new thing, like dunder methods, search for them and stuff. This is how I learnt
would you suggest others to do the same 🤔
no
anyone know how to fix this? code:
fail to see ze code
do people really think we can read their minds
Never
can someone help me with checking if the message is under a category?
Hey @echo wasp!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
The token is None
Seems like os.getenv() is returning None
let me get code my code is to long to send normal and not my first time
we're currently waiting for u to give more information
Just do one thing
u told me my answer did not work

Add these lines on the top of the file
so what's the error
read the code
from dotenv import load_dotenv
load_dotenv()
I have it
Oh, u r doing that
Discord.py end.
not u pusdk
Damn
if ctx.category.name != "category name":
return
this does not work
bru
do you really have category name in your code
wdym
I mean exactly what I asked
elaborate on how that doesn't work
yeah, my story was somewhat like that, i wanted to make a custom help command so asked people how to do it they linked me Stella's gist, i didn't understand shit and then i started from the beginning and searched a discord.py tutorial luckily, i watched a tutorial from a experienced guy that knew what he was doing, i skipped to the second part where they gave users a list of which things they need to learn prolly because of those dumb comments, i saved it and started reading them and creating small projects from then i think im improving day by day
the list was of decorators, classes and stuff like that
Seems like most people graduate after making their own custom subclassed help command
Makes sense as it has to touch upon inheritance and classes, but it you learnt that before discord.py it would be super super easy to do
does not work bro XD
even if i write under "category name" category
it still blocks the command
pretty hard for a self taught one tho they dont knoe what they need to learn plus i sucked at english and was a kid
i was like 13
That is true, how well you learn is dependent
Just feels like to me most people are skipping a few steps sometimes but what am I to say about that
yeah
I do understand why people would do it though as I can see discord bots being a fun project for beginners
when using the discord.Member type hint, is there any way to check if the given input is a member object, if not use the string version of the input?
It was just last year in around September when I started Python.
async def plays(self, ctx, user : discord.Member = None):
"""Defaults user_id to author, but checks if a user is provided. If so, change user_id to targeted users"""
embed = Embed(color = Color.green())
guild_id = ctx.guild.id
target = ctx.author
try:
target = self.client.get_user(user.id)
except AttributeError:
user = str(user)
i tried this but it still tried to use the member object
Dpy automatically converts it to a discord.Member instance
yeah that's very vague, can't help you
hmmm, so theres no way to get the raw input itself after using the type hint?
yeah it was around 1 year for me as well
How can i fix my discord token error?
Raw input can vary. It can be an ID, a name, or even a full username bro
Recheck your environmental vars
Why we shouldn't use replit for host?
yeah ik, thats why i have the try/except block. if the input is a valid user it'll have an ID, if not it'll raise an error which tells me it's NOT a user
the goal would be the except block tells the program its NOT a member instance, therefore use the raw version
i described the issue
for one, it's slow as fuck
As I said, it's gonna be a discord.Member instance 99.9% of times
It won't be a discord.Member instance only if the person isn't in the guild or is an invalid person
im preparing myself before making my own discord api wrapper (just a simple one) i looked up the docs of the socket and http module i think im doing too much lol
this is kinda what im aiming for. by default it'll be a discord.Member instance. It then checks if a valid user was given (either based on ID, username, nick, etc). If it's NOT a user in the guild or is an invalid user, take the input itself and NOT the member instance. idk how possible that is if at all using the typehint
the member instance is used to search my DB for that user's socials. so if no user is given, itll target the author instead OR use the raw input as the username
Then u can just use use isinstance
if not isinstance(member, discord.Member):
!d str.isnumeric
str.isnumeric()```
Return `True` if all characters in the string are numeric characters, and there is at least one character, `False` otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric\_Type=Digit, Numeric\_Type=Decimal or Numeric\_Type=Numeric.
This will return True if it's an ID
it will return True even if its some random numbers tho
Yea
But that's upto him to figure out how to use it, since discord.py would always convert a correct ID to discord.Member instance
then try and convert the number found to a user object, and if returns none i can assume its a random # input
!d discord.Object
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
yeah the logic behind it all makes sense its just too early in the morning to make any sense rn
so im struggling to put everythjing into words
well they don't let .env files be created
lmfao
if member.id == ctx.bot.id:
return await ctx.send("no")
does ctx.bot.id mean the bot's ID?
No
ctx.bot.user.id returns the ID
oh ok thx
can someone dm a .env file? that has like hi or something in it?
HI = Your value
MYXI = thats me
TOKEN = your token```
If I had a regular embed command could I just import slash commands and etc and add the slash commands into the embed command code?
what lib are u using tho
Wdym?
discord.py doesn't have slash commands
Ho how can i create a mod mail bot whit python
Yes they do.
They have slash commands. lol
link me the docs
i said docs
ik slash commands exist
if guild.get_member(member.id) is not None:
acts = member.activities
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
playing = ""
listening = ""
streaming = ""
watching = ""
competing = ""
act = 'None'
if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities):
act = "Listening to {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities):
act = "Playing {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities):
act = "Streaming {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
if member.activity is None:
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
if not act:
act = 'None'
else:
if member.activity.type == ActivityType.listening:
act = ("Listening to {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
elif member.activity.type == ActivityType.watching:
act = ("Watching {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
elif member.activity.type == ActivityType.competing:
act = ("Competing in {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
else:
pass```
i think my bot might be racist
¯_(ツ)_/¯
Bro what.
that doesn't proof that it is from discord.py
Omg.
BD momentum
you might be using "third party extensions" or "forks" of it which is not a part of discord.py directly
It literally is.
sh its for experimental purposes to see if my bots showing the right status
its not officially supported, it will not be in the docs of the original library
[...] 
But it can still be used.
that doesnt make it a part of discord.py

@client.event
async def on_message(message):
if message.content.startswith('s'):
web = message.content
await web.delete()
How to delete an user message using discord.py?
I guess.
await message.delete()
what is web = message.content
anyways can someone help me with this? for some reason it doesnt show what users are playing, but it works fine when i test it on bots whos activitys are 'playing' 
Gives the message content
await web.delete() will work?
No
@slate swan are slash commands supported officially on discord.py?
can someone recommend me a database that can be accessed by more than one bot and won't break the bot's cache or anything?
No
But they CAN still be used right?
tx
It's not built-in but there are third (actually kind of fourth) party libraries to make slash commands work with discord.py
Okay ty.
bot doesnt show when users are 'playing', only other bots, anyone wanna help?
What?
what
i thought i was discreet with the way i said it is there something thats not understood or
Do you have the presence intent enabled?
mhm
and all intents
i hate intents with a passion
discord should take the decision to add intents back, it fixes absolutely nothing
!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.
any other ideas?
What is your code
@client.event
async def on_member_join(member):
await member.send(f'Welcome {member.user.name}')
it gives me error
if guild.get_member(member.id) is not None:
acts = member.activities
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
act = 'None'
if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities):
act = "Listening to {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities):
act = "Playing {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities):
act = "Streaming {} ".format(member.activity.name.replace("(UNREGISTERED)", ""))
if member.activity is None:
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
if not act:
act = 'None'
else:
if member.activity.type == ActivityType.listening:
act = ("Listening to {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
elif member.activity.type == ActivityType.watching:
act = ("Watching {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
elif member.activity.type == ActivityType.competing:
act = ("Competing in {} ").format(member.activity.name.replace("(UNREGISTERED)", ""))
else:
pass```
u didnt classify member
Just do member or member.name if you don't want the discriminator
am stupid
not member.user.name

lol
why would u need to send files to dms
why a field value cannot be a string?
just answer 
lol
i forgot what it was rip
Too do the file idk much about it but you can use member.send
ik
!d discord.abc.Messagable.send.file
d discord.abc.Messagable.send.file
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
check the file param of send method
See the file kwarg
its the same thing for a webhook LOL
@slate swan the source u asked for
lol



ek
!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.
Same i only got 4 hours of sleep
😭
gotta leave this channel from today, time to make my own api wrapper of discord api https://cdn.discordapp.com/emojis/436911467598577664.gif?v=1&size=40
@client.event
async def on_member_join(member):
await member.send(files='path??')


so the path works?
@slate swan u asked for the sourceeee
also gg pro coder, ur name says everything winrar op
Stop pinging youve pinged him like 3 times 

Indeed 
Imagine not paying for winrar
Yeah, what a shame..

Anyways, going back at writing awesome documentation 
Good luck bro
..


is there a way so i can make it that buttons are only interactable for the person who ran the command?
I think a check could work idk not familiar with buttons
Kraots is tho hes mr.disnake
i want to check if the interaction user id is the same as ctx.author.id but i cant figure out how
if interaction.user.id != ctx.author.id: this is what i am using, but it says that ctx is not defined
Good to see you infernum
how would I allow users to dm a file to my bot, and then I'd receive the file in my log channel?
my current one only takes in the text message. Just need help with getting the file
@sullen shoal how are you doing?🤔
Good to see you too
Good to hear from both of you🤔
is disnake a lib like discord.py?
a fork of discord.py
i am using nextcord.py and i wanna stay on nextcord.py
Im good
nice
Disnake is probably better
then idk
Disnake = best fork
🥲
Im not forcing you i just recommend it
Anyone?
ik you arent forcing me
im just looking for a way to do it in nextcord
did u try asking the nextcord staff
Cant help you sorry i only use disnake
they told me to ask here ;-;
oh
lol
damn lol
i would say support here is better than in their discord server
i met one of their devs even they advertise disnake 
LOL
!d discord.Message.attachments
A list of attachments given to a message.
thank you I'll take a look!
use replit
no...
What site i can use for hosting?
buy a vps
then idk
anyway I can add roles via their role name? For context I have a ton of roles that are just 1 number increasing, and member’s roles ascend in numbers the more they interact. I can add a role based on their current role number + 1
Am i tripping?
no you arent, replit just still exists, thats all
why people still use it? now thats the real question
why wouldnt
replit is complete doo doo
Idk maybe cuz is horrible
role_names = ['role1', 'role2']
for i in role_names:
role = discord.utils.get(ctx.guild.roles, name=i)
await member.add_role(role)
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
🙏
I like it
@velvet kindle best free option is heroku not good compared to vps but best option over replit
ok
Uptimerobot
or maybe because you haven't seen real hosting
Why yall recommending random websites from the internet
couldnt you make your code look good and alot more optimized by memorizing two strings,
rich_presence = "\<:rich_presence:907387984226173008\>"
acts = member.activities
activity_name = member.activity.name.replace('(UNREGISTERED)', '')```
act = f'Listening to {activity_name} {rich_presence}"```
ugh discord not letting me put the emoji name correctly
class ChooseClass(nextcord.ui.View):
def __init__(self):
super().__init__(timeout=30)
self.value = None
# button for knight class
@nextcord.ui.button(label="Knight", emoji="⚔️", style=nextcord.ButtonStyle.blurple)
async def knight(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "knight"
self.stop()
# button for archer class
@nextcord.ui.button(label="Archer", emoji="🏹", style=nextcord.ButtonStyle.blurple)
async def archer(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "archer"
self.stop()
# button for wizard class
@nextcord.ui.button(label="Wizard", emoji="🔮", style=nextcord.ButtonStyle.blurple)
async def wizard(self, button:nextcord.ui.Button, interaction: nextcord.Interaction):
self.value = "wizard"
self.stop()
is there ANY way on this holy earth that i could check if the user id is same as the interaction user id
using nextcord.py
that thing looks pretty similar to discord.py implementation, overwriting interaction_check method should work
utils/paginator.py lines 87 to 88
async def interaction_check(self, interaction: disnake.MessageInteraction) -> bool:
return interaction.author.id == self.ctx.author.id```
the problem is getting ctx.author.id inside the class
just pass the Context to the class?
when i pass ctx to the class it says it doesnt have a value
cogs/imagesearch/_cog.py lines 20 to 23
paginator = Paginator(ctx, embeds=embeds)
paginator.message = await ctx.send(
embed=paginator.current_embed, view=paginator
)```
im trying my best to not have to migrate to disnake
that is not even related to disnake
more of something to do with OOP
Paginator(ctx, embeds=embeds)
im passing the ctx instance to my paginator
this is something which was added in discord.py 2.0 iirc, so it should be same for disnake and nextcord
how do i make sure i have these library?
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
from discord.utils import get
from dotenv import load_dotenv
run it
How do I make %x show the date like (de_DE)?
or catch ModuleNotFoundError
ok how do i install from command line?
pip
pip install pakage_name
class ChooseClass(nextcord.ui.View, ctx):
the moment i give ctx to the class this happens -
NameError: name 'ctx' is not defined
bro
we inherit from other classes there
add the parameter to __init__
and add it to the instance
def __init__(self, ctx):
like that?
!e
class foo():
def __init__(self, ctx: commands.Context) -> None:
self.ctx = ctx
# the first parameter of every non static method is the instance of the class. it can be named anything, but please name it self.
ctx = 'oof'
f = foo(ctx)
print(f.ctx)```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
oof


You have to type hint ctx cuz it doesnt have the bot decorator right?
nah its not needed, just tells the IDE what it is, helps with autocompletion
also makes it easy for others to contribute
Ik whats a type hint -_-
oh
😔
did i answer your question tho or im confused
I just expect something more but thx
now im even more confused-
Just forget it😭
One site of hosting on mobile?
alright then
I dont think you can host on mobile
Sad
you may use pydroid to host your bot using your phone
amogus
Thats so cursed😭
I use pydroid but my bot it is not on
this is self promotion
oh maybe if i had an old phone that I don't use anymore
- can't you just test yourself?
well no..
gonna be slow tho
i am testing the button thing in which only the command user can interact with the button
so i need 2 people, one who will issue the command and one who will try to click the buttons
its fine tho i will just go ask my 0 friends for help
expensive tho why not buy vps
Vps or a rpi are the best options
tbh i have a raspberry pi and its not really worth it
vps are cheaper and more powerful
yea
my pi can hardly handle it
looks like you got the worst one
its the 4b, top tier everything - max ram and cpy speed
Vps are better in my opinion cuz they have their own internet and its fast and a rpi is good but you need to rely on your internet and power
yes but for me i have my local network i dont like the vps services
everything is on my own
ok use whatever you want
thats weird
should be working fine
You don’t powerful anything to host a discord bot. It’s literally a discord bot. Most bots don’t even need a gig of memory to do the things they do.
yea
and thats a fact is it? 
A rpi is like 100 bucks when digitals ocean lowest pack is like 5 bucks a month so you can get a year and a half
just a small script have to be running all the time
how to get the name of the user's role
try having a bot on 200k servers that works its ass off
That’s why I said mid level bot
!d discord.Role.name role.name
The name of the role.
how are you using the bot
200k is not mid-level that’s over 100 shards
i dont understand anything
A bot with like 100guilds takes like 40 to 60 mb so no you don't need a gig of ram even
it was just on big servers
at the moment if you got 200k servers ofc you will be able to get more powerful service for the host ofc
Yes it’s recommended to get a high level vps or dedicated machine at that point
i took it off the servers to give my pi a chance at life
oh
poor little boy was crying
who
For mercy
Nothing its offline rn
is it open source
i mean what is the bot about
Wdym by open source
general moderation
github repo
is the code. ope
Multi function bot
cool
No
and who the hell gonna working hard then let the code an open source
anyone need help with their bot?
no
most devs
If people need, they ask..
then some kids come and use your code like its nothing
well some
A idea would be nice
whats wrong with that lol
just shows you're selfish
Idc if my bot is open source tbh 
But u still have skills lmaooo
Bro chill
most devs dont really care about their code, theyre proud of it, and thats enough for them
Yeah
!d discord.Object
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
?
True
#bot-commands
I mean i made my bot Open source for people to self-host. I don’t really care. As long as they respect the license that’s on the repo. There won’t be problems. 👌
if you bot is open source , other people may try to improve it as well
i will
there is something called "time" Which you spent creating and diligence with and then someone comes and uses it and he did nothing and the issue may reach a more problematic
i cant handle myself when i see dumb code
so basically you're being selfish lol
Tbh i dont care if people copy my code i take it like a compliment
'its mine mine and noone but mines'
whats the syntqax
ofc if they are respect it but what im talking about that there is something kids doesnt
microsoft windows moment
???
do you know what a liscence is
in github
what do you think
90% of the time the liscence means nothing
thats why im talking about that
🤔
That’s false
as in, its stuff like 'dont sell my code'
Have you seen licenses like Apache

Or GNU
i mean my bots liscenced
Some licenses allow you to take the code, some don't
how to get the names of all the user's roles
Like MIT your basically allowed to do whatever with it
discord.Member.roles will return the list of user's roles, each is a discord.Role object
but with bots like these, noones going to try and sell it or distribute it
Sometimes you cannot but licenses always mean something
let them take the code but there is some people don't just take it
I do.
Open source is amazing
But have you seen the Unlicense license. https://unlicense.org
I like teaching others so i let my code be public sometimes
If its a diecord bot I don't see why make it closed source
I wouldn't make my code open source unless I fully am okay with others copying it and not even giving me credits. That's how you become a good member of the dev community.
as i said If you have the full possibility to make your project restricted to property rights but most people do not do so
We going a bit off-topic, eh?
A license is basically what gives you rights on your code, up to you to decide if your rights on your code means nothing.
yeah diecord bots
well ye
thats why im saying at this basic level with a million of the same bots that liscence means nothing; noone wants your code anyway
Most people who see no license on a repo usually think it's free to do whatever on it 
It's sometimes hard to believe
But not really at the same time
People have no respect over intellectual property
it do be that way :l
Theirs always that someone🤷♂️
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
If you then get sued or get a DMCA takedown that's your issue 
Me who copied a line of code to my bot from github: 
how do i make it a string
The name of the role.
discord.Role.name(roleid)?
uh oh

😿



send help
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
They wont find me if im in russia
This will return a discord.Role object, then you can use the name attribute.
they have the member
and they probably gonna end up actually doing discord.Guild.get_role()
im anyone would like a discord bot hmu. im bored and would like a project to do
without using role id
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
Lmao
Get what I mean.
can bots use emojis from guilds they are in, like from server x use that emoji in server y?
im being as iqless as possible
Yes
Yes. Discord bots have a limited edition of Discord Nitro.
This will be fun
discord.utils.get(message.guild.roles)
??????????????????????????????????????
Limited?
Yes. Then pass a name or an id attribute.
act = 'None'
if guild.get_member(member.id) is not None:
acts = member.activities
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
for activity in member.activities:
if isinstance(activity, discord.Game):
act = ("Playing {} ").format(member.activity.name)
elif isinstance(activity, discord.Spotify):
act = ("Listening to {} ").format(member.activity.name)
elif isinstance(activity, discord.Streaming):
act = ("Streaming {} ").format(member.activity.name)
elif member.activity.type == ActivityType.listening:
act = ("Listening to {} ").format(member.activity.name)
elif member.activity.type == ActivityType.watching:
act = ("Watching {} ").format(member.activity.name)
elif member.activity.type == ActivityType.competing:
act = ("Competing in {} ").format(member.activity.name)```
for whatever reason, the bot only displays the status' of other bots. doesnt seem to work on users (only the playing status)
E.g. get(guild.roles, name="admin")
is it possible to get the name without passing an attribute ajrwhroawbroawurhwarb bruawehrawurhawrhawjdf;we
like i want to add their current role + 1 since roles are numbers
I am creating a "product review" command I want that when I call the command I can enter the quality and rating, for example:! review 5 stars test
if I try to write this it prints the message on stars and rating, but I want it to print the message 1 of the star and 2 for the rating
async def review(ctx, *, message):
embed = discord.Embed (
title = 'Product Review',
description = f'Stars: {message} \ n Rating: {message} '
)
await ctx.send(embed = embed)```
#discord-bots message
remove repeated code first.
wait i can use less lines?
and fix the formatting so that its human readable
and still optimize it by a bit
I can't give you 100 balls and tell you to give me my favorite ball, while I never told you which one is my favorite. Same thing with the bot. You cannot ask it to get a role without specifying which role you want.
wdym? cuz currently i have member : discord.Member
¯_(ツ)_/¯
need some help^^
is it possible to see .exe source code? or transfer it to .py?
no lol
Discord still adds spaces? 
ok forget it i tried my to explain it, be happy with that spaghetti
.
Then pass 2 different parameters.
@client.command()
async def review(ctx, stars, *, message):
embed = discord.Embed (
title = 'Product Review',
description = f'Stars: {stars} \ n Rating: {message} '
)
await ctx.send(embed = embed)
also its not the right channel to ask it
uhm
lemme try
wouldi still need the py if guild.get_member(member.id) is not None: acts = member.activities act = [i for i in acts if isinstance(i, discord.CustomActivity)] if act: act = act[0]?
you cant find their current role?
like the current role they have
then add a role that is 1 more than their current role
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
what i am saying is that, your code contains a lot of repeated that, which isnt good, what you could do, is memorizing it by making it a variable
it always helps to debug faster when the code is clean
im going to kill myself
lol
ok works thanks
i tried what u explained to me, for whatever reason it says im listening to sublime text 
role = discord.utils.get(message.guild.roles, name=str(int(discord.utils.get(message.guild.roles name#wtf)) + 1))
await message.author.add_roles(role)```
I'm watching Spotify.
sorry i dont know any of this lol
im playing netflix.
What are you trying to achieve?
Why not just pass the role ID to the add_roles method
i have 50 roles
1,2,3,4,5 etc.
and like the more they interact the higher their number
You want to add a role?
add a role higher than their current one
show code after fixing the formatting
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
Yea that
ive put it on a test command for now
@commands.command()
async def bb(self, ctx, member : discord.Member = None):
if member is None:
member = ctx.author
rich_presence = ""
acts = member.activities
activity_name = member.activity.name.replace('(UNREGISTERED)', '')
act = f'Listening to {activity_name} {rich_presence}'
await ctx.send(act)```
It can also take in a snowflake
add a role 1 higher than their current one
So u can also add the role ids
Create a role with a higher hierarchy?
...(position= )
If you want to add a role to a user, its hierarchy depends on its hierarchy in the server itself.
the name of my roles are 1, 2, 3, 4, 5, 6, 7, 8 up to 50
💀
I'm losing brain cells.
what is the output of member.activity.name
😃
so i have 50 roles named 1, 2, 3, 4, 5 so on. i want to add a role thats 1 more than a user's current role, if the user has no roles then it adds the role "1"
It's because you have Listening to at the start of your string.
right
sublime text is the name of activity

i will ask later i suppose
how am i meant to get the activity type then?
i will try repharsing if needed
without repeating code
What do you mean you want to add a role to be "1 more"?
so lets say they have the role "34"
is discord.Activity.type a thing?
!d discord.Activity.type
The type of activity currently being done.
i want to delete the role "34" and add the role "35"
over a certain condition (ive already got that covered)
and would that show for watching, competing, streaming, listening to, listening to spotify (yes 2 different things), playing
Delete the role from the guild? Or remove it from the member's roles?
tias
remove it from the member's roles
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
ok
how do i find the users CURRENT ROLE so then i can add a role thats their current role + 1
thats my only question
You want to get the list of the member's roles?
ive gone and done this
actype = member.activity.type
act = f'{actype} {activity_name} {rich_presence}'``` but the output is "ActivityType.playing Sublime Text "
referring to this
i want to add a role to the user thats 1 more than their current one
how do i get their current role as a string object
!d discord.ActivityType
class discord.ActivityType```
Specifies the type of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity"). This is used to check how to interpret the activity itself.
check attributes of it
^
would something like this work? 1 sec lemme type it out
wait nvm i just ran it through my head it wouldnt work
actually i think youre using the wrong attribute, one sec
i think you have to create a dict
a dict?
how can i know whether the attachment is a image or a video??
not familiar with technical terms
file extention id guess
extension*
something like,
a = ActivityType
d = {
a.playing: "playing", a.listening:"listening"
}```
something like that
i gotta go now, afk
Check if the file name ends with .exe or an img extention.
Best is to use mimetypes
how do I send a emoji from another server?
How would you do a token part of the bot i do this and get this error
install the module?
i tried
pip install python-dotenv did you install that?
i needs to be redone it doesn't support dotenv
Yeah it's python-dotenv
thx
it was smth like <id&id> right?
thanks i did pip install dotenv
<:name:id>
ah
Also calling your own main file Bot.py is very confusing not to mention potential break points.
thank you
it needs to have a colon before the name too
oh I see
@commands.command()
async def bb(self, ctx, member : discord.Member = None):
if member is None:
member = ctx.author
rich_presence = ""
acts = member.activities
activity_name = member.activity.name.replace('(UNREGISTERED)', '')
a = ActivityType
d = {
a.playing: "Playing", a.listening:"Listening to", a.watching: "Watching",
a.streaming: "Streaming", a.competing: "Competing in"
}
act = f'{d} {activity_name} {rich_presence}'
await ctx.send(act)```

so i have 50 roles named 1, 2, 3, 4, 5 so on. i want to add a role thats 1 more than a user's current role, if the user has no roles then it adds the role "1"
get roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
there @stone moon
read the docs
ppl dont spoonfeed code here
thats what githubs for
can you call a function inside another one?
okay
yeah
im wokring in a cog for my discord bot, and its saying the function im trying to call isn't defined
#party creator
@commands.command()
async def party(self, ctx, user: discord.User):
with open("users.json", "r") as f:
data = json.load(f)
party = []
party.append(str(ctx.author.id))
party.append(str(user.id))
if not set(party).issubset(data):
await ctx.send("One or more users is not registered.")
party.remove(str(ctx.author.id))
party.remove(str(user.id))
else:
print(party)
await ctx.send(f"Party made!\nMembers: {party}")
gen_party_id() #THIS FUNCTION RIGHT HERE OFFICER
data[party][f"Party: {partyid}"]
with open("users.json", "w") as f:
json.dump(data, f, indent=4)
I defined gen_party_id above in the code
redefine it in the command maybe?
¯_(ツ)_/¯
just putting the dict won't work, you have to get it, using the get method of dict
!d dict.get
get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").




