#Basic Pycord Help
1 messages · Page 4 of 1
error with view: AttributeError: '_EnumValue_ButtonStyle' object has no attribute 'disabled'
code:
(there are also more same buttons bellow)
P1 = "\N{Regional Indicator Symbol Letter X}"
P2 = "\N{Regional Indicator Symbol Letter O}"
EMPTY ="\N{white large square}"```
also this if you nead
lmk if i nead to send more info/code
if not player1:
self.button1 = discord.ButtonStyle.green
self.button2 = discord.ButtonStyle.green
self.button3 = discord.ButtonStyle.green
self.button4 = discord.ButtonStyle.green
self.button5 = discord.ButtonStyle.green
self.button6 = discord.ButtonStyle.green
self.button7 = discord.ButtonStyle.green
self.button8 = discord.ButtonStyle.green
self.button9 = discord.ButtonStyle.green
self.button1.disabled = toggles[0]
self.button2.disabled = toggles[1]
self.button3.disabled = toggles[2]
self.button4.disabled = toggles[3]
self.button5.disabled = toggles[4]
self.button6.disabled = toggles[5]
self.button7.disabled = toggles[6]
self.button8.disabled = toggles[7]
self.button9.disabled = toggles[8]
self.button1.emoji = emojify[0]
self.button2.emoji = emojify[1]
self.button3.emoji = emojify[2]
self.button4.emoji = emojify[3]
self.button5.emoji = emojify[4]
self.button6.emoji = emojify[5]
self.button7.emoji = emojify[6]
self.button8.emoji = emojify[7]
self.button9.emoji = emojify[8]
button1 is a ButtonStyle not a button
so what do i do?
Unfortunately, I could not convert the image normally into bytes so that discord.File can read it later. How can you store an image in RAM without resorting to saving to disk?
any decent guides floating around about how to make embeds prettier? still learning what you can do in them
wanna make this embed a lil prettier looking lol
Just save all Embed attributes somewhere in your notes
https://docs.pycord.dev/en/stable/api/data_classes.html#embed
Examine all methods and attributes of the Embed class
Some classes are just there to be data containers, this lists them. Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes. Nearly all clas...
(ignore the spacing issues, that's just me not paying attention in my f strings lol)
anyone know you can get the bot object from an interaction object without setting an attribute called "bot" with __setattr__?
actually i really want to use tab-spacing/alignment or something similar in my embed
but I dont know if discord uses tabs
interaction.client
thats the same as ctx.bot?
Wdym?
It is
like just lining up all the guesses/points/accuracies/etc from user to user
like if I could make a table or something
got it thanks, it would keep all custom attributes set correct?
Tias
You can use up to three fields in a row
Also you can use selection which equalizes the size of all characters
yeah, can do monospaced but thats also a lil ugly
I just want something prettier than
flappity: Guess: 75 Points Earned: 1 | Accuracy: 5.0%
New Score Total: 10 (56.0% accuracy)
but i dont know if I have a lot of options
Except on mobile
No other way
You can use images?
It's a good way out
in theory but then I'd have to generate images on the fly too lol
but like, that's also not a bad idea
i'm sure python could do that pretty easily. maybe latex? :D
Teach me how to upload images edited by the Pillow library 😉
Edit the correct var?
generating scorecard images sounds kinda goofy but it would also mean i could get it as pretty as i wanted lol
I can’t convert to bytes, saving images to a HHD is a bad idea. I do not know what to do
If you wanted to change them dynamically, then that would be stupid, but no
well this is round-end stuff, so at the end of a game round it calculates the scores, updates the score database, and then spits out the round-end scorecard
so they'd never change
Why is saving the image bad?
It tells me this is the owner of the hosting I use. I was told to save the image to RAM, but I have no idea how to do it
On the Internet, people either convert to bytes if they do not want to save, or save the image
Have you even tried to Google all your questions
You can pretty much find an answer online
Do you have /dev/shm or is /tmp a ramdisk
Or /var/run
Yes
Then use that
so with groups, does the /command just inherit the group name?
like if I made a group named "dat" and then created commands as part of that group like "start", would the command then be /dat start
actually, nm. i just tried and it does
i'm not used to things being intuitive >_>
you can even create a sub group
like /dat start name
Here's the slash cog groups example.
hmm, so with these bottom three fields, is there any way to get them to take up the full 3 columns for each field?
where they'd be displayed above each other instead of side by side like that
I'm running into a problem where my embed field value was exceeding a length of 1024 so I gotta figure out some alternative
i forgot which way round it is but add inline=True when you add the field i think
oo
Personally i'd add a check if the char length is over 1024 and split into a cont. field
Hello. Quick question. Interaction doesn’t have an attribute to add_reaction. So what should I use
what do you want add a reaction to?
Is the message with the embed sent as a response/followup?
Response
you can get that message with await interaction.original_response()
and let's say you store it to a variable called response, you would use await response.add_reaction(...)
Yeah
But I’m not gonna store it
So it would just be interaction.original_response.add_reaction
sorry, I don't think that's how coros work
you would await for the original_response
what?
what version are you on
in older versions, it could also be interaction.original_message()
hmm. so I know there's available ways to find a username based off a userid, but I'm having trouble figuring out how I might do that in secondary libraries that aren't part of my main bot file or my commands file. would I just have to pass the bot object to the function directly so it can use bot.get_user() maybe?
I"m so not used to structuring stuff like this lol
yes, that would be easiest
that sounded more complicated at first but i guess that is pretty simple
usually dont have to use the bot object for stuff, mostly just pass ctx around from function to function lol
And interaction has interaction.client
Hey. This is my code
@bot.tree.command(name="appraise")
async def appraise(interaction: discord.Interaction, *, item_name: str, set_price: str):
item_name = item_name.title()
response = await interaction.original_response()
down_arrow="⏬"
left_right_arrow="↔️"
up_arrow="⏫"
embed = discord.Embed(title=f"{interaction.user}'s Appraisal: {item_name}", description="Please React with the Following Reactions to help appraise this Item!")
await interaction.response.send_message(embed=embed)
await response.add_reaction(down_arrow, left_right_arrow, up_arrow)
My error is: 404 unknown webhook
For await interaction.original_response()
You first send the message
You're doing original_response and then send_message
@bot.tree.command(name="appraise")
async def appraise(interaction: discord.Interaction, *, item_name: str, set_price: str):
item_name = item_name.title()
- response = await interaction.original_response()
down_arrow="⏬"
left_right_arrow="↔️"
up_arrow="⏫"
embed = discord.Embed(title=f"{interaction.user}'s Appraisal: {item_name}", description="Please React with the Following Reactions to help appraise this Item!")
await interaction.response.send_message(embed=embed)
+ response = await interaction.original_response()
await response.add_reaction(down_arrow, left_right_arrow, up_arrow)
Yeah
What’s the plus for
well, i THOUGHT it'd be easy
Oh
ctx.bot.get_user just gives me None when passed an ID. maybe one of these other methods work lol
try await ctx.bot.get_or_fetch_user
oo will try
For future reference, get_user returns None if the user isn't in the bot cache
more like, there is no user in the bot cache with that ID.
Well
ahh ok, get_or_fetch user worked, though now i have to figure out how to get from there to whatever nickname they're using on the server
same thing SQUID
🤥
superconducting quantum interference device
why didn't you just get the member object instead of the user object
cuz i'm still looking through the docs and trying to figure out what i'm doing D:
i dont think ive looked at member objects at all even lol
What the fuck is await (file=image)
aha, fetch_member is probably where i need to be looking
or rather guild.fetch_member()
yep guild
urgh. one of my things is timing out somewhere along the line
well, maybe. it's almost like it's losing the interaction when doing ctx.respond()?
never mind, it's just my internet crapping out lol
Its like you have to respond in 3 seconds and with bad Internet you gonna have a lot of issues with slash commands at testing
I accidentally erased ctx.send
sorry of stiped question but i can use localization text from crowdin?
So what var do i change?
how do i get the list of all roles in a server for the autocomplete thing? just getting the list of all role ids is also fine (i would just need the logic for turning role ids into their role names LOL)
yeah, that's what i just found out -- luckily it's moving to a VPS soon
so that error should happen much less
i need to add some error handling for it though
which probably just means wrapping my respond command in some if statement and then failing gracefully if the error pops up
right now if it fails it leaves a flag set lol
or alternatively it sounds like if you get a response in right away you dont have to worry about the timer. so maybe I could add a .respond() at the start of the command to make the 3 second thing a non-issue?
how i can make Localizations?
https://pypi.org/project/pycord-i18n/ exists but imo it is uhm... not for everyone imo
i saw in pycord guide, it will work?
yup
its possible import localize from file? like Eng_GB
%join_welcome_pm% = Hello pls read rules etc
?
Idk tbh because I never used i18n but I think you can
Localizations are a way to make your bot more accessible to your users. Learn all about localizations now!
.tias
anyone here familiar with using wavelink with py-cord?
is there a way to get the id of the person typing out a slash command?
like some way to do the thing in the image
that actually works
positions = (
("gk", 95, 325),
("rb", 235, 380),
("lb", 235, 255),
("cm", 385, 318),
("rf", 455, 520),
("lf", 463, 110),
("cf", 525, 318)
)
if position in positions:
data[teamroster][position].append(player.display_name)
for position1 in positions:
with open("rosters.json", "r") as json_file:
data = json.load(json_file)
text, width = function(position1[0], team, font, data)
Im.text((position1[1]-(width/2), position1[2]), text, (0,0,0), font=font)
image.save(f"picture{team}.png")
why is this not saving the file?
oh yeah this worked great thank you
ctx.respond and not ctx.send
edited, but wasnt really my point.
cogs?
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
thats at least how i went about it
Yeah cogs are nice and easy
Is there anyway that I dont have to add this to each file
import discord
from discord.ext import commands
class Greetings(commands.Cog): # create a class for our cog that inherits from commands.Cog
# this class is used to create a cog, which is a module that can be added to the bot
def __init__(self, bot): # this is a special method that is called when the cog is loaded
self.bot = bot
@commands.command() # creates a prefixed command
async def hello(self, ctx): # all methods now must have both self and ctx parameters
await ctx.send('Hello!')
@discord.slash_command() # we can also add application commands
async def goodbye(self, ctx):
await ctx.respond('Goodbye!')
@discord.user_command()
async def greet(self, ctx, member: discord.Member):
await ctx.respond(f'{ctx.author.mention} says hello to {member.mention}!')
@commands.Cog.listener() # we can add event listeners to our cog
async def on_member_join(self, member): # this is called when a member joins the server
# you must enable the proper intents
# to access this event.
# See the Popular-Topics/Intents page for more info
await member.send('Welcome to the server!')
def setup(bot): # this is called by Pycord to setup the cog
bot.add_cog(Greetings(bot)) # add the cog to the bot
just
@bot.slash_command(description="Add a suggestion")
async def hello(ctx):
await ctx.respond(f'Hello {ctx.author.display_name}.')
I was thinking about using temp files
but idk
than stay in your main file or create your own slash command
you dont really need to copy everything, its just there for reference purpose
im trying to make like extras basically the main file is going to be obfuscated and I want that users can add there own commands
its way simpler if you have it without setup etc..
you can just do this
cogs/greetings.py
import discord
from discord.ext import commands
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
Greetings = SlashCommandGroup(name="Stuff", description="Stuffs")
@Greetings.command(description="Add a suggestion")
async def hello(ctx):
await ctx.respond(f'Hello {ctx.author.display_name}.')
imports
bot = blah blah blah
bot.load_extension(cogs.greetings)
bot.run(token)
havent tested though
my thought was that I make temp files and they just read them and makes it into this
I think it would work
How do I add a view using discord.Bot.add_view() when the View I have requires parameters that are only given when running a slash command (i want to make it persistent)?
I have this command that lets an admin make a Select view to allow for users to select a role in the list
however in creating the Select view i pass in the options (the roles that the user can select) that are given from the slash command
so when i want to make it persistent by adding it to the bot I don't have that data anymore
do i need to serialize the options list or is there a better way to go about it?
you need to make them nullable
I dont see how this'll let my view be persistent
like change my constructor to be __init__(self, options:list[discord.Role] | None?
and if None is passed just do nothing?
yep
alr ill try that
it worked! thanks
Also can multiple persistent views use the same id?
is there a way i can get around discord on mobile only allowing photo uploads in slash command attachment optoins
Do internal checks.
it says in the docs that discord id are 18 digits long, what UNSIGNED INT() length would I need in a database ?
Which docs?
because they aren't
I think it was a other type, I just saw they are snowflake yes
so it would be UNSIGNED INT(64) ?
I would suggest uisng strings
why use strings ? I would take more memory for no benefits
Hey for some reason roleInteraction.message is None. Does anyone know why that is?
something to do with the cache?
the message is only defined if the interaction was sent from a button or select menu
that makes sense. how can i get the message ID of the response? roleInteraction.id?
well, you can use await roleInteraction.original_response() to get the actual message
thanks! you're a big help
yw
lmk if you still nead this, cuz i have file, just @me
What are these commands called?
Message commands
To be precise, Context menu commands
how can i turn of mention author on reply edit
initial reply doesn't have mention author, the edit does though, putting ", mention_author = False" after it doesn't work
You can't
Discord limitation
That's sad
gravitational pull of the sun
i have code: (bellow) and i get an error :
AttributeError: '_EnumValue_ButtonStyle' object has no attribute 'disabled'
what do i change?
gravitational pull of the sun
Weren't you already told you were trying to apply .disabled to a buttonStyle
no?
oh sorry
.
but how do i disable it then in the code?
Do you want to disable them all?
only the selected
Get the proper buttons
With self.children
Or with their callbacks
Idk how you're creating them
so self.children[0] and then disabled?
Tias
can I dm you?
sure
in a button callback, does interaction.message.id not give the id of the button that the message is in?
its giving some different id
actually
msg = await ctx.respond("abc")
print(msg.id)``` this is giving the wrong id
that is not how you get it
oh how do i get the msg id then
msg = await interaction.original_response()
If Im not wrong
this is in a slash command
sry, ctx.interaction.original_response()
ah ty
anyone here familiar with using wavelink with py-cord?
how do i subscribe for only specific intents
import discord
bot = discord.Bot(intents=discord.intents.members(bans=True, guilds=True))
i couldnt understand that
what if i need messages.Content + Embeds + Attachments
Embeds and attachments are not an intent
The list of contents is here
https://docs.pycord.dev/en/stable/api/data_classes.html#discord.Intents
Some classes are just there to be data containers, this lists them. Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes. Nearly all clas...
You might be mixing up permissions with intents.
yea 🤦
You can use it just like how the examples do for dpy
Just the setup hook part will be a bit different
You can use a one-time listener for on_ready (one-time listeners are only available on master branch rn)
Or you can inject the setup in bot.start by subclassing
can u have a look at https://discord.com/channels/881207955029110855/1136235638606286898 pliz 👀
Oh hmm
when I have a message with an attachment and I want to edit this message and remove the attachment, how can I do this?
Pass an empty list to the attachments kwarg when editing
can my global on_command_error listener catch an error from within a with statement? The error seems to just be getting ignored atm
(Using a bridge command if that's relevant)
You know that one if for prefix commands? ;3
Haven't used regular prefix commands before
ah this was a problem with my context manager object's __exit__ not the command
You have to Check with if else
Or send the message as hidden
But it would get auto deleted after some time
My bot's code is organized into many extension files with cogs; is it possible for me to create a command group in one cog and add subcommands to that command in another file's cog?
I tried simply importing the command group from the other cog's class and it works very confusingly - it's as if it recognizes that the command has been created (I loop through cmdGroup.walk_commands() to show the user a list of available subcommands) but i can't actually run the subcommand
yes, I think someone created something for it
1 sec.
This one but its for slash commands
does that apply to my use case?
since there's only one cog in that file and it doesn't import any of the other modules
if i have a slash command that runs itself/another slash command, how can i use await ctx.defer() without it saying the interaction has already been responded to
The bot cannot run a slash command
i meant the function of a slash command
@bot.slash_command(name="test")
async def test(ctx, abc:str=None):
if test == None:
await test(ctx, "abc")``` like that or something
Why do you need to run the function again
tbh i could just
@bot.slash_command(name="test")
async def test(ctx, abc:str=None):
if test == None:
abc = "abc"``` instead
but if i want the closest thing to a command alias then i'd need to run it
guys how they did this?
After digging for a bit https://github.com/Dorukyum/pycord-multicog is basically what I'm looking for however it only works for slash commands, any way to apply this to text/bridge commands?
@commands.command()
@commands.has_permissions(administrator=True)
async def kickall(self, ctx):
guild = self.bot.get_guild(1053331335005098044)
members = guild.members
channel = guild.get_channel(1053331335005098047)
KickedMembers = []
for member in members:
if not member.bot and member != guild.owner:
try:
CurrentTime = datetime.datetime.utcnow() - member.joined_at
if len(member.roles) == 1 and CurrentTime.days > 1:
await member.send(" ")
await member.kick(reason="Did not verify in 3 day duration, or was denied.")
KickedMembers.append(member.name)
except discord.Forbidden:
pass
print("Running kickall command...") # Print statement for debugging
if KickedMembers:
await channel.send(embed=KickedMember)
else:
await channel.send(embed=NoKickedMember)```
The else statment does not run at all, this only started after i added the check for current time etc to the if statment, I think this may be a indentation error but could use a little help
member.send(" ")
You cannot send an empty message
Ignore that sorry should have said, Just removed the inside as it had a link
So no errors?
No errors at all no
And what does it send
Nothing
I run the command, it does not kick or respond (It shouldnt kick as it does not meet the criteria)
But it should respond with
NoKickedMember = discord.Embed(title="No un-verified members found", description="No members were found unverified or denied to the server so i have not kicked anyone.", color=0x10BDF6)
Want the full file?
Yeah it did before i added the and CurrentTime.days > 1: part, to check if they've been in the server over a day
but now nothing happens at all (As said, the not kicking is okay)
I have a task for this too, plus the command i've shown, The task code isnt yet updated & still works fine
but isnt updated with the and CurrentTime.days > 1: check
I'm asking if it works now
No, It does not respond
Sorry if i went into detail a bit
Thats correct,
@tasks.loop(hours=168)
async def kickall_task(self):
guild = self.bot.get_guild(1053331335005098044)
members = guild.members
channel = guild.get_channel(1053331335005098047)
KickedMembers = []
for member in members:
if not member.bot and member != guild.owner:
try:
if len(member.roles) == 1:
await member.send("")
await member.kick(reason="Did not verify in 3 day duration, or was denied.")
KickedMembers.append(member.name)
except discord.Forbidden:
pass
if KickedMembers:
await channel.send(embed=KickedMember)
else:
await channel.send(embed=NoKickedMember)```
That is my task code
It has no extra check, and works fine
I've tried coparing them but cannot find an issue
(Is slighly outdated to what i've used to fix it, but didnt work)
alr
@commands.has_permissions(administrator=True)
async def kickall(self, ctx):
guild = self.bot.get_guild(1053331335005098044)
members = guild.members
channel = guild.get_channel(1053331335005098047)
KickedMembers = []
for member in members:
if not member.bot and member != guild.owner:
CurrentTime = datetime.datetime.utcnow() - member.joined_at
print(CurrentTime.days)
if len(member.roles) == 1 and CurrentTime.days > 1:
await member.send("")
await member.kick(reason="Did not verify in 3 day duration, or was denied.")
KickedMembers.append(member.name)
else:
await ctx.send("test")``` My updated code, still no response & didnt print
Ill go fix my variable names once i fix this then ty
No print
Put it below the append
@lofty parcel
Yeah
@commands.command()
@commands.has_permissions(administrator=True)
async def kickall(self, ctx):
print("e")
guild = self.bot.get_guild(1053331335005098044)
members = guild.members
channel = guild.get_channel(1053331335005098047)
KickedMembers = []
print("e")
for member in members:
print("e")
if not member.bot and member != guild.owner:
CurrentTime = datetime.datetime.utcnow() - member.joined_at
print(CurrentTime.days)
if len(member.roles) == 1 and CurrentTime.days > 1:
await member.send("")
await member.kick(reason="Did not verify in 3 day duration, or was denied.")
KickedMembers.append(member.name)
print(KickedMembers)
else:
await ctx.send("test")``` Quite a few prints, nothing printed though.
Not even the e?
Then your command isn't registered?
I uh, don't really know
Is it a cog?
Are you loading the cog?
Yeah it loads, it worked earlier
Got a response
I removed the permission check for admin?
I mean, the check should throw the error
After all
In console or sending a msg if you're catching it
Yeah should for sure send in console, plus i have a check for it
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send(embed=NoPermissions)```
is the command properly registered in the bot?
I recommend checking indeed, if it's a debug guild command or public command
Public commands take some time to update
It's weird as fuck
Does anyone know why my slash commands arent working?
well sorry
im just using an example from the documentation,
@bot.slash_command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
await ctx.respond(f"Pong! Latency is {bot.latency}")
it's just not showing up for some reason? ive had the bot running for like a day now and still
show the full file
import discord
from dotenv import load_dotenv
import os
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
bot = discord.Bot()
@bot.slash_command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
await ctx.respond(f"Pong! Latency is {bot.latency}")
# run is in run.py
why do you have a discord.Client?
remove that
aw, that was it i was creating the bot under a client and not the bot itself ig
thx
how to make some commands shown in this list only to certain roles?
That only works with permissions
what are permissions
How to add slash commands in Discord BOT with Python?
I want to add /custom commands.
with @discord.default_permissions(the permission)
My Internet was to slow for it xd
lmao, saw you typin but then it just went away
I think I don't understand
what should I put in instead of "the permission"?
This error.
mute_members=True its like the prefix commands
.rtfm default_permissions
The docs explain it
Uninstall discord and other stuff
You're using replit?
No don't know, just imported discord module and please im new in discord bot, totally zero knowledge of this. please help.
Where do you write the bot?
In VsCode.
I hosted it with my public ip in my private server
@lofty parcel Do you know any VS Code extension showing something like this?
Can you show the pip list?
You mean pip installed packages?
Somethin like what exactly
I don't see 😭
it's called pycharm
I just want to have it at VS Code x3
I hate pycharm
?tag install
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
I hate vscode for full-scale projects
I use now VS Code for C# because it got so many crazy updates for it
Tried to migrate my bot code to pycharm and it started yelling at me. Not happening again. I only use it for uni
yeah because your code doesn't follow pep
Uninstalled discord.py & Installed py-cored. Now? And thanks @little cobalt
GIT is installed.
It messed up my imports
Now, discord Bot error has been resolved but this coming.
Are you sure you're on the latest version of the library?
I copied and pasted this code.
That's as old as my dead grandma
Update the library
This appears while updating.
||sudo pip install||
?
bot is running.
how can i go about pinging a certain user in pycord
.rtfm Member.mention
.rtfm get_member
async def bot_calc(Crazy, first: discord.Option(int), second: discord.Option(int)):```
How to add description to parameters of command in discord.py?
Here's the slash options example.
Thanks @shell radish .
yw
Thanks again it is working. :D
how to use stable diffusion with discord bot? @shell radish Please if you know reply.

no?
- Don't just ask for code. You need to understand the language if you are coding instead of blindly copying someone's code. When asking for help, do not insist on getting just the code; we are here to help you learn, not copy.
I'm here to learn.
No code, but to understand.
Is there a way to detect when the bot gets temporarily disconnected from Discord (because of something on Discord's end I guess) and, like, print something to the console when it does?
.rtfm on_disc
tyvm
Yeh sry, I really need to explore all the discord. functions. Haven't played with them much.
yeah, you should use a string instead
resolved this by using role_id: discord.Role then doing role_id.id
i really needed the integer value and using a string feels very
janky
I assumed there was something that wouldn't work with discord.Role
Like I assumed that solution already crossed your mind.
I want to check if the user has admin permissions.
Here's my try:
def check_is_admin(user, guild):
roles = guild.roles
adm_roles = []
for role in roles:
if role.permissions.administrator:
adm_roles.append(role)
flag = False
for role in adm_roles:
if user.has_role(role):
flag = True
break
return flag
But here's error "User object doesn't have has_role attribute".
I also tried to make it via user.roles, but it falls with error "User object doesn't have roles attribute"
you can just use user.guild_permissions.administrator
is it possible to enter multiple roles in SlashCommand option, either with discord.Option or discord.SlashCommandType?
I know it's possible using discord.Converter but I'd rather prefer using Slash Command
I don't think you can have a list of roles within one command option, you could of course do something like option1, option2, option3 ...
ah yeah, thanks for the answer
.rtfm member.guild_perm
i trying make multi lang like
msg/responses save ing lang.json and import msg like welcome_info it will send of preferred language of discord, how i can real to implement language checking?
hey?
how can i pass the context of the autocomplete to a function:
async def banned_member_autocomplete(self, guild):
banned_users = [entry async for entry in guild.bans(limit=1000000)]
return [f"{entry.user.name} ({entry.user.id})" for entry in banned_users]
@commands.slash_command(name="banned_users_example")
@option("user", description="Pick a banned user from this list", autocomplete=banned_member_autocomplete)
async def autocomplete_banned_users_example(self, ctx, user: str):
# Your logic to unban the selected user goes here
# Replace the following line with the code to unban the user
# Example: await ctx.guild.unban(user)
await ctx.respond(f"You have successfully unbanned the user: {user}!")
I want the autocomplete thing to be a list of banned users. I keep getting: AttributeError: 'AutocompleteContext' object has no attribute 'bans'
how to create a timestamp like this? 5 minutes ago? the time is changed without editing the message
So is it possible to set a custom status?
If you mean something like that, yes.
And pycord already has pr on that: https://github.com/Pycord-Development/pycord/pull/2206
did you fix it?
You don't. Autocomplete only receives one argument: ctx which is AutoCompleteContext
hey guys I want to ask something how can I add my avatar to a photo via pillow?
okay i learned
Hello. How can I create a function in a bot that will periodically fire when the time expires?
.rtfm tasks
Thank you
autocomplete functions get AutocompleteContext objects, not Guild
.rtfm autocompletecontext
How do we make a command that can only be used by server owner... Without the Members Intent
with @commands.is_owner()
Isn't that for bot owner?
yea I was reading bot owner xd
I don't want any Member Object data just want to limit the usage to the owner only
You could use @commands.has_permissions(administrator=True)
There is not really a thing for the server owner
I don't want admins to use the command
or you do a if else
What if else?
if ctx.author.id == ctx.guild.owner_id:
...
else
"Error"
That requires Members Intent ig
I don't have that
I applied but got rejected twice
you dont need intents for a slash command
The thing is. Whether it is a normal or a slash command. Guild.owner will return None
cz no intent
try owner_id
One sec
but you only get the id
How can I find out the number of members in voices?
that fixed it
owner_id works and it doesn't require intent
Thanks
Tipp for the future : consider putting your token in an .env file :P
or .json file ;3
yml ftw
.txt pls
Okay thanks for the tip :D
is there any difference between discord.Bot and discord.exts.commands.Bot?
i didnt found any
?tag clients
No tag clients found.
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
tysm
tysm
take out the style
oh nvm
that should work
is that your whole class?
uh that's not how you write a view class
Here's the link example.
@deft kestrel try this example ^
no, that's not right at all
you need to add the button to the view
Excuse me. How can I change the guild banner?
.rtfm button
discord.ui.button
discord.Button
discord.Button.custom_id
discord.Button.disabled
discord.Button.emoji
discord.Button.label
discord.Button.style
discord.Button.to_dict
discord.Button.type
discord.Button.url
discord.ui.Button
discord.ui.Button.callback
discord.ui.Button.custom_id
discord.ui.Button.disabled
discord.ui.Button.emoji
discord.ui.Button.from_component
discord.ui.Button.is_dispatchable
discord.ui.Button.is_persistent
discord.ui.Button.label
discord.ui.Button.refresh_component
No
I solved the problem, I'm sorry
oh overread "link" buttons
link buttons have a default color iirc.
can't change indeed
Where can we report bugs on the py-cord library ?
What is the bug?
The on_reaction_add event (if that's what it's called I'm not sure) is failing and not firing on some added reactions
Do you have reaction intents?
is the same happening if you use on_raw_reaction_add?
I did not try
on_reaction_add only works on cached messages
That's to say ?
oh yea, its like get_channel
if the message is not found in the internal message cache, then this event will not be called
that is why I use only on_raw_reaction_add
It's very likely that it comes from there 👀 I'll try then and I'll let you know
Is there a way to use the regular client.wait_for() after a buttom is pressed?
on_presence_update is still saying idle instead of offline and discord are saying its not their fault
Use callbacks
There a way to use the default permissions decortator with slash command groups? I want the behavior that the default_permisions gives of hiding commands from people who don't have the proper perms but on an indivual command basis with my slash command group.
Add the decorator to each command?
Tried that, doesn't work for some reason, works fine with normal slash commands
No, permissions are given on a top-level basis
Ah so I'm guessing it's a discord api thing
I guess I can just switch to non grouped commands, it's only bot config commands anyways
maybe consider using a UI-based approach?
I was, but the config involves choosing channels and I'm not sure how easy that would be through ui
Wdym choosing channels?
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, timeout. Methods cls View.from_message, def add_item, def...
Pass the description to discord.Option
how do i get the current shard the bot is serving in ?
.rtfm Option
discord.Option
discord.Option.converter
discord.Option.to_dict
discord.ThreadOption
discord.OptionChoice
discord.OptionChoice.to_dict
discord.SelectOption
discord.SelectOption.default
discord.SelectOption.description
discord.SelectOption.emoji
discord.SelectOption.from_dict
discord.SelectOption.label
discord.SelectOption.to_dict
discord.SelectOption.value
discord.commands.option
discord.ApplicationContext.selected_options
discord.ApplicationContext.unselected_options
discord.SlashCommandOptionType
discord.SlashCommandOptionType.sub_command
discord.SlashCommandOptionType.sub_command_group
can we set custom status of bots using py-cord?
.rtfm activity
discord.Activity
discord.Activity.application_id
discord.Activity.assets
discord.Activity.buttons
discord.Activity.created_at
discord.Activity.details
discord.Activity.emoji
discord.Activity.end
discord.Activity.flags
discord.Activity.large_image_text
discord.Activity.large_image_url
discord.Activity.name
discord.Activity.party
discord.Activity.session_id
discord.Activity.small_image_text
discord.Activity.small_image_url
discord.Activity.start
discord.Activity.state
discord.Activity.sync_id
discord.Activity.timestamps
.rtfm presence
discord.on_presence_update
discord.Client.change_presence
discord.Intents.presences
discord.AutoShardedClient.change_presence
discord.ext.bridge.Bot.change_presence
discord.ext.bridge.AutoShardedBot.change_presence
discord.ext.commands.Bot.change_presence
discord.ext.commands.AutoShardedBot.change_presence
discord.Invite.approximate_presence_count
discord.AutoShardedBot.change_presence
discord.ApplicationFlags.gateway_presence
discord.ApplicationFlags.gateway_presence_limited
discord.Bot.change_presence
discord.Guild.approximate_presence_count
discord.Guild.max_presences
Is there a way to detect when a Persons starts speaking in a Voice channel? (I want it to then start recording)
And if yes is there a way to detect silence time base example 0.5 sec so that i can use that to stop the recording?
on_presence_update is still saying idle instead of offline and discord are saying its not their fault
try fetching the user
works on my machine
I had a similar problem a while ago, when checking is_on_mobile
fetching user always gives offline
huh, I do a get, not a fetch apparently 🤷
wait i forgot what i did
sorry, fetch_member
i did fetch_member and it said offline always
@bot.event
async def on_presence_update(before, after):
print(f"{after.display_name} - {after.activity} - {after.status}") # idle instead of offline
member = await after.guild.fetch_member(after.id)
print(member.status) # always offline```
idk how i could be doing something to break it
yeah, I get offline when I fetch too
The API doesn't return privileged information regardless of intents iirc
but get_member works correctly, shows dnd, idle, online, and offline
do a get_member
okay ill try
maybe discord fixed something
i just restarted bot and it works fine
with normal after.status
Gateway FTW
wait how do i set a button label to a variable if i can't use self.variable because its not in the function
What
Wdym it's not in the function
class buttons(discord.ui.View):
def __init__(self, variable):
super().__init__()
self.variable = variable
@discord.ui.button(label=self.variable, style=discord.ButtonStyle.grey)
async def callback(self, button, interaction):
dshfujisdjhiuo```
like i cant do that
?
just subclass button
Or self.callback.label = self.variable
i feel like i saw somewhere that you can use duration in an ephemeral=True ctx.respond() and it'll only last that long? I was trying to find it again but i could not
like ctx.respond("asdfb", ephemeral=True, duration=15)
You mean "delete_after=15"?
oh is it delete_after
coros don't have attrs
now I need to figure out buttons
They are really easy to use
and you use interaction instead of ctx
ahh gotcha
i have a /dat scale command and I sorta wanna just add a button to the embed that triggers the same function
does pycord support that new feature where you can add a custom status of bot?
On master branch, yes
on pypi?
?tag install
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
no, I mean is it available on pypi yet?
no
ohhk
I would better wait for it coz uk the master branch is unstable and I don't want to break anything in my bot
:)
It's very stable lol
60% of the times, it works everytime

But yea it's pretty stable... until I commit
🤣
How would I get the message id of the message that my views are on?
ok thank you
and this is in the buttons code
Im getting an error, AttributeError: 'buttons' object has no attribute 'view'
sorry im relatively new to pycords views
do you have a super().__init__()?
could you show your code?
yes
class buttons(discord.ui.View):
def __init__(self, client, ctx):
self.client = client
self.ctx = ctx
super().__init__(timeout=None)
@discord.ui.button(label='Ban', style=discord.ButtonStyle.danger)
async def ban_button_callback(self, button, interaction):
msg_id = self.view.message.id
basically that
im just trying to get the message id of the message the buttons are on
its above
bruh I thought you meant that you're in a button class when you said this
how can I disable dm commands for my bot? 👀
like it doesn't listen to msg cmds and no slash cmds appear there too
you can add the @discord.guild_only decorator
ohkk
class buttons(discord.ui.View):
def __init__(self, client, ctx):
self.client = client
self.ctx = ctx
super().__init__(timeout=None)
@discord.ui.button(label='Ban', style=discord.ButtonStyle.danger)
async def ban_button_callback(self, button, interaction):
- msg_id = self.view.message.id
+ msg_id = self.message.id
how do u add that - and + thing? with color highlight 👀
ok thx!
diff
and what would i use to return the user id of the user that clicked the button?
```diff
class buttons(discord.ui.View):
def __init__(self, client, ctx):
self.client = client
self.ctx = ctx
super().__init__(timeout=None)
@discord.ui.button(label='Ban', style=discord.ButtonStyle.danger)
async def ban_button_callback(self, button, interaction):
-
msg_id = self.view.message.id
-
msg_id = self.message.id
```
yes
interaction.user.id
ok thx
oo, ty
am I guaranteed to have all channel IDs for a guild? I dont want to make an api call to fetch_channel just to check id.
hi! i want typing hints for pycord functions. What type should i use for ctx?
async def func(ctx: type?)
discord.ext.commands.Context from docs doesnt help
also, is there anything like middlewares from aiogram in pycord? https://docs.aiogram.dev/en/dev-3.x/dispatcher/middlewares.html
Are you using bridge commands, application commands or prefixed commands?
For the middleware thing we have events that you can catch. If that is what you mean
Ex: on_message
can I add a description to a choice of discord.Option's choices list?
Nope. You can only pass a description for the option itself, not the choices within the option.
ohkk
curious if there's any other real time game bots like mine (where you start a round, accept submissions, and then process em), i'm sorta curious to see how other people handled things, figure out if I'm doing things weird af or if they're normal
Hello, how would creating a separate cog for each command affect performance and is it reasonable?
You should create cogs for commands categories
how?
Group commands with the same purpose in the same cog
like in my case I have my guessing game in one cog, will have another game in a different cog, will have another cog that will look up data (unrelated to the game)
oh, i see
at least that's how I'm using cogs
structuring my bot with the main .py file to run the bot in the base folder, and then subfolders for each cog that will contain all the files that that specific cog uses
thanks
How can i defer the button?
channel = bot.get_channel(id)
await channel.send
My code is really complexe xD
I see that Interaction doesnt have defer
Hello. Is it possible to change the value of options?
class Name(discord.ui.View):
def __init__(self, name_list):
super().__init__(timeout=None)
self.options = name_list
@discord.ui.Select(
placeholder="title",
min_values=1,
max_values=1,
options=self.options # doesn't see it
)
async def select_callback(self, select, interaction):
...
I think add_option can fix your problem
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, timeout. Methods cls View.from_message, def add_item, def...
I never used I don't know
I will try it, thank you
Hi, I'm trying to check whether a member has a role by using member.get_role(id) with the id of the role. This always returns None even though I know the user has that role. What gives?
My code looks like this. First I fetch the role id and it is found. Then I try to find all members with that role, but nothing is printed.
user.roles is also an empty list
If you have members intent, you can use guild.members instead of guild.fetch_members
I have that enabled in the developer page for the bot, but guild.members returns an empty list
I was also wondering about that
https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
I think I do: client = discord.Client(intents=discord.Intents(message_content=True, guild_messages=True, guilds=True, messages=True, members=True))
I doubt you’re using discord.Client. Do you have a bot instance?
I do not. I am actually using this client created here.
Is that wrong?
what is the difference between a client and a bot?
you’re telling me that you don’t have any commands?
Not slash commands at least. This is an old bot
It does cleanup of the server by deleting old messages
No text-based commands either?
It does have some text commands that are prefixed by !
But I have implemented those myself. I'm not using any API for them
💀 ok
I'm parsing messages in a designated bot commands channel and if they start with "!" I do things
But you're saying I should change from a client to a bot?
how are you getting guild
client.fetch_guilds
yeah that’s why
that's why what?
try using client.guilds
oh
apis don’t return privileged info
my brain is not comprehending how to do buttons lol
Does somebody has any idea?
what are you trying to do?
interaction.response.defer
Thanks ❤️
hey guys
Option(min_value=50, max_value=99999, required=True, input_type=discord.SlashCommandOptionType.integer)
what did i do wrong here?
oh okay I fixed
need some help in https://discord.com/channels/881207955029110855/1140329082098290799 please thanks
Is there some way that I can unload all my extensions when the bot crashes?
Like i have a list of cogs, some of which have data that needs to be dumped on exit
is there a built in way to do this in pycord or does python have something for this?
?tag localfile
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
hmm. I can't do await ctx.respond(embed=e) I'm guessing? or maybe ctx.respond has a file option too
OH you can
Hi, I'm a selector but I don't understand, I have this error, any ideas?
TypeError: function() argument 'code' must be code, not str
whats the "proper" way to handle server/channel permissions? Right now I just have a hardcoded dictionary
server_permissions['serverid'] = ['channel1', 'channel2'], etc and it just checks if the source of the command is in that dict lol
doesn't seem like the cleanest way
wdym "handle"
Zamnn!!
bot tracks all their guesses and calculates the average after each round, plots it
kinda neat :D
so I have a question
i have a command /dat graph
This displays aforementioned graph. Is there a way I can make an optional parameter /dat graph [user] so they can look up other users, or simply use it without the parameter to get their own?
I tried adding it to the command but it wasn't optional
I"m sure there's probably a rtfm for this already
name: discord.Option(discord.Member, required=True or False)
will try it. i wanna see what the autocomplete behavior is
Any ideas? :c
Could you show your code?
class SRewards(discord.ui.select):
def __init__(self):
super().__init__(
placeholder="List",
select_type=discord.ComponentType.string_select,
min_values=1,
max_values=1,
custom_id="rewardSelector",
options=[
discord.SelectOption(
label="1 | 3 votes",
description="-",
emoji="🔘",
value="-"
)
]
)
async def callback(self, interaction):
select_description = self.description[0]
await interaction.response.send_message(f"{select_description}")
heck ye. thanks!
and what is the full traceback?
yes
The problem appears when I create my class
class SRewards(discord.ui.select):```
sorry, I'm asking for the full traceback and you haven't provided any
Sorry, I thought you were asking if this was the only traceback, I don't have anything more as I have this error in an "except".
But I found it, I used the example to create my class, I forgot to capitalize it... A beginner's mistake, I'm ashamed.
alright, happy coding
thats always fun
i had an error where i had something divided by i + 1 and could not figure out why it kept throwing divide by zero errors
i was sitting too far from my laptop, because it was actually i + i
lul
LOL
once i was doing py for i in something: somethingelse[1] = somethingelseelse and i was confused for like a week where this random 1 came from
bc i thought it was an i
heya, since the username change, I've needed to change how I display usernames in command responses (through slash commands) - ctx.author.display_name is returning my normal Discord username (lowercase: angry_pineapple) when my actual display name has uppercase letters - is there a workaround for this?
which py-cord version do you have?
I'm running version 2.4.0
I didn't even think to check that lol
1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.
Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
the last line ^
you look familiar
ah whos this loser
:(
Hi, what could this be related to?
I am sending a model with 2 textinput: (modal.to_dict())
{
'title': 'Translation',
'custom_id': 'b8feae83fedc6c68513030239f321a7c',
'components': [
{'type': 1, 'components': [{'type': 4, 'style': 1, 'label': 'Enter the transfer amount (RUP)', 'custom_id': 'e851de9759cc77c8d2eda54abd93dd42', 'placeholder': '8264.76', 'min_length': 1, 'max_length': 7}]},
{'type': 1, 'components': [{'type': 4, 'style': 2, 'label': 'Comment', 'custom_id': 'a6cf017d28b9e2d3af16074f6198aa6e', 'placeholder': 'Input may be empty', 'max_length': 128, 'required': False}]}
]
}
I get the error:
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7, 10}.
How are you creating the modal?
Can you show your modal class
Do I need to replace a list[tuple] with a list[inputText]?
class TextModal(Modal):
def __init__(self, title: str, inputs: list[tuple]) -> None:
self.data: tuple = None
super().__init__(
*tuple(
InputText(
label = text_input[0],
placeholder = text_input[1],
min_length = text_input[2],
max_length = text_input[3],
required = text_input[4],
style = text_input[5]
) for text_input in inputs
),
title = title,
timeout = 360
)
async def on_timeout() -> None:
raise Exception("Timeout")
async def callback(self, interaction: Interaction) -> None:
self.data = (interaction,) + tuple(children.value for children in self.children)
async def text(interaction: Interaction, ...) -> tuple[Interaction, str]:
modal = TextModal(
title,
[(label, placeholder, min_length, max_length, required, style)]
)
await interaction.response.send_modal(modal)
await modal.wait()
return modal.data
That shouldn't matter
What's the full error and traceback?
Ignoring exception in view <MenuPage timeout=900.0 children=6> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Translation' emoji=None row=1>:
Traceback (most recent call last):
File "....AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\ui\view.py", line 421, in _scheduled_task
await item.callback(interaction)
File "....Bot\ext\bank\views.py", line 207, in transfer
i, _ = await global_transaction(interaction)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "....Bot\ext\bank\interactions.py", line 405, in global_transaction
interaction, _value, _comment = await texts(
^^^^^^^^^^^^
File "....Bot\ext\bank\interactions.py", line 105, in texts
await interaction.response.send_modal(modal)
File "....AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 1164, in send_modal
await self._locked_response(
File "....AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\interactions.py", line 1198, in _locked_response
await coro
File "....AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\webhook\async_.py", line 222, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7, 10}.
I use 2.4.1.dev160+g017e4adb, and also tested the latest stable release
A modal is sent to global_transaction (receives the card number for transfer) and a call to texts (which also sends a modal), it turns out that it is impossible to send a modal in an interaction that returns from another modal
I want to add language support for my Discord bot, what do I need to do for this?
Slash commands
Or interactions
are there any sort of easy options for putting some sort of divider here? like some sort of horizontal line or maybe even splitting it into a separate box within the embed? i don't wanna do something ugly like just write "------------"
I don't suppose you can actually send two embeds in one message?
you can. just pass a list of the embeds to send or respond. For example await ctx.respond(embeds=[embed1, embed2])
oooh
that's the easy fix then
could just have my function return the stats embed and a scorecard embed and then pass those along to respond. that seems the right way to do it
I guess there's no way to get the header formatting (###) into an embed? Tried it in an embed field name but it just put the characters ### lol
It will almost certainly only work in description and field value
Not title, field name, and other stuff
laame
I suppose I could just... not give the field a title and only give it a description
pseudo-title
eh, works for me, i'm happy enough with this lol
What about functionality for like.. if I have a list of users, highlighting the reader's name only (like displaying it as @user like a ping would look)? I can see how i'd make ALL of the names user links, but i feel like its a stretch to only display the reader's name in that way
when i try installing on vps py-cord dev version it cannot be installed
Update git
and what is your python vresion?
is there a solution for some (but not all) users getting "This command is outdated"? Or do they just have to wait
they just have to wait and they can refresh it with ctrl + r if they use the desktop app
Update pip and git
And setuptools
done
what should i do now?
pip install -U pip setuptools
already done
ahh gotcha
now that i have a relatively stable bot I need to start looking into the PROPER way to do server permissions, command permissions, web ui integration, etc
hmm try uninstalling pycord and reinstalling
also do you use venv or conda or smth
nah
only dev
try running your bot tho. that might work
no wont work either
yikes
then try creating a venv 💀
oh also update wheel
pip install -U pip setuptools wheel
how to make a venv and install stuff in it
google might be the best resource for that
or chatgpt
chatgpt has been my best friend while writing this crap lol
i love giving it a function and being like "is there a better way to do this?"
worked now with venv bot is running
Does there exist any functionality to highlight a user's name within a message containing multiple names?
like if it's showing a list that's:
user1, user2, user3
if user2 is viewing the message, it will have their name highlighted, but not user1 or user3. And same situation if user1 or user3 views it. if user4 views it, none will be highlighted
awesome
nope
message content it meant to be static yk
How long does a discord attachment get stored by discord for? Is it forever? I want to store evidence images on a moderation bot and am wondering if I can just store the discord attachment link
as long as the message isnt deleted, it will be available
yuh, figured. was hopeful there might be some black magic but alas
there are some other weird cases too. like channel or guild gets deleted but attachment is still available. but dont rely on that stuff
if you really want to make sure the attachments dont get deleted, you can download them on your local computer ||or simply reupload to a a private channel in your own guild||
Anyone have any idea why get_member_named, and get_member are only returning None even though I know for a fact the member is present in the guild?
print(mrpguild)
invitechannel = guild.get_channel(443614533815369728)
print(invitechannel)
invite = await invitechannel.create_invite(max_uses=1)
print(invite.url)
row = sheet.find(appnumber).row
#get values from sheet
userid = sheet.cell(row, 2).value
print(userid)
user = mrpguild.get_member_named(userid)
if user is None:
userlongid = sheet.cell(row, 4).value
print(userlongid)
user = mrpguild.get_member(userlongid)
if user is None:
usernick = sheet.cell(row, 3).value
print(usernick)
user = mrpguild.get_member_named(usernick)
print(user)
get_member can return None if the member is not anymore at the cache
you should do a check if get_member is None use fetch_member
same for get_channel
is this new with discords username changes? This use to work perfect
How would I do this?
basic if else with python
How can i create such Stats?
google "python statistiken erstellen" ;3
xd
what are your intents
its not ideal tbh. especially when doing it repeatedly
but your choice
Any idea what could be the issue with the get_member
It all started when discord started rolling out the new naming system
i dont think that would cause this issue, but try using the master branch
it has the username updates n stuff
pretty stable rn too
I just noticed @discord.default_permissions(manage_channels=True) decorator does not work for slash commands in cogs (as in, anyone can use the command). What absolutely n00b mistake am I making?
Oh... The command is in a slash command group. Can default_permissions only be used for the whole group, or can I use it with a specific command in the group?
only for the entire group
Just stumbled upon that conclusion as well. tyvm 🙂 Looks like I can possibly still check within the function and manually handle it with the following code?
if ctx.author.guild_permissions.manage_channels:
await ctx.respond("You have the required permission to use this subcommand.")
else:
await ctx.respond("You do not have the required permission to use this subcommand.")
Only downside is the command would still show in Discord's context menu for commands...
how to check if command is used from prefixed command or slash command?
yes
are you using bridge?
yes
.rtfm bridgecontext.is_app
Is there some sort of decorator that lets me run checks (for example on_message to see if its a bot) to make it so i don't have to add```if message.author.bot:
return
I belive i checked for this before and the only thing i saw was before a task
why do you have multiple on_messages to begin with
Because of different features i don't want in the same cog i guess?
Fair enough though tbh
I would just make one on_message and call different functions/methods
Hm didn't think about that 🤔
.rtfm intents.pre
.rtfm intents.memb
I can spell
Will on_message detect new messages if intents.members is False ?
yes
Alright
literally 3rd line of documentation comment 💀
Mb, I read that and then deleted my message asap
Does discord freely approve for intent.members compared to message content intents?
My use case is only for syncing level roles for members who rejoin
the members intent request bar is lower than the message content intent. As long as you clearly and concisely explain why your use case follows Discord's 4 Criteria for Approval, then you should be fine.
Oh
Why could the order of the reactions be incorrect
I tried adding a 1 second wait but that didn't fix it
just use buttons
It's actually a user-message autoreaction
my poll command doesn't have a wait and they're in order
Hmm, strange
for i, option in enumerate(new_options):
...
await response.edit_original_message(content=message)
m = await response.original_response()
await m.add_reaction(emoji)```
although I guess I do edit the message as well, that will add a delay
I'll try using enum
but no artifical sleeps
are you doing async sleep?
await asyncio.sleep(1)
oh yeah you are in your screenshot
idk 🤷
Using enum fixed it for me, thanks!
enum ≠ enumerate.
using the tasks loop thing if there’s an error does the loop stop?
my loop keeps stopping and idk why
and i can’t see if it errors bc im sleeping when it happens
what is the best database for a bot?
Hey. How can i do an list of members with an specific role? I want to make an uprank system and all members with an specific role (my team members) should be shown in an Option field in the slash command+
No tag db found.
?tag database
No tag database found.
what
There is no best database, but here’s some that are recommended: MySQL, Postgres, SQLite, MongoDB, and MariaDB.
You'd need to use autocomplete
how?
How what exactly
autocomplete
Is it possible to use SQLite if my bot performs a lot of database processes?
Here's the slash autocomplete example.
do you have an example for me?
yes
The repo does
.
and what happens if the bot starts recording 2 data at the same time? this seems unacceptable in SQLite
You need to get the role in the autocomplete
Then return the members names
And then internally in your command you'll need to get them by name
if you use the correct library, then race conditions are handled
can you pls come dm and help me there a bit?
