Best matches for guil.create_role in pyc
#General Help
1 messages · Page 11 of 1
b!rtfm pyc on_guild_join
I couldn't find a documentation with the name on_guild_join! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake
b!rtfm pyc on_guild_join
Best matches for on_guild_join in pyc
ty
can i make my bot check messages that have certain text in them then respond based on the text?
like if the message is a banned word it'll be deleted and maybe the bot will send a message
mightve gotten it
if "word" in message.content
@open bear was the 4041st person to join Pycord
@wet heart was the 1124th person to join Pycord

eee
why does this not work?
@potent rivet was the 6199th person to join Pycord
on_message doesn't take ctx
ah
Events dont have context
oh yeah
You're looking for await message.channel.send()
ok thanks
its being weird, It wont send the message if i say the message but if the bot sends it then it will respond
Do you have messages intent
Can someone help me pls?
How can I edit an interaction more then once?
async def approve(interaction):
await interaction.response.edit_message(
embed=embed, view=view.clear_items()
)
artists =await api.libary_artists(ctx, username)
await interaction.response.edit_message(
embed=discord.Embed(
description=f"rawr",
color=0x7289DA,
)
)
await interaction.response.edit_message(
embed=discord.Embed(
description=f"awr",
color=0x7289DA,
)
)```
**discord.errors.InteractionResponded: This interaction has already been responded to before**
interaction.message.edit if you already responded to it
Hi, How do I know the user who pressed a button is the same user who called the button?
hm
you'd grab the id of the person who called the interaction then compare it with the person that pressed it
I can get the one who pressed a button, but the one who called the button is no
ah i see
can i see the code you used?
https://guide.pycord.dev/interactions/ui-components/buttons/
was going to point out if you used slash commands then getting the authors id of who sent the command wouldnt be hard
Learn all about implementing buttons in your Discord Bot using Pycord.
you probs could try message.author == ctx.author
hm
@desert dagger
in the MyView class you could
def __init__(self, author : discord.Member):
self.author = author
What should I use instead
oky
i did say interaction.message.edit if you already responded which it says u have
Have you tried await asyncio.sleep()?
It work, Thank you
sweet
Can you help me here too? #980463476860403713
not really sure. but it seems like your code doesnt like you editing self
Maybe try explaining what the code does and show a bit more code in there and someone will help
From here add the message he is modifying
https://prnt.sc/WTkfm9SbTqzg
What theme is that?
you could try interaction.message.edit idk
#980463476860403713
hes asking for ur theme in your IDE lol
lmao
I just want it to send message.content only when the ticket is open and the player has sent the second message
user sent a message or bot?
is your workflow:
- Create a category if it doesn't exist
- Create ticket
- Send welcome embed in ticket
- let user know ticket has been created
- send message.content after embed has been sent? @slender lintel
dss I have yes I have all only when a welcome message comes in the chat is sent again message.content.
so u want message.content to be sent in the ticket channel? too
He will yes I send later a screenshot what I mean
your code creates the channel, sends an embed and lets the person know their ticket has been created. but if channel already exists it just sends message.content in "channel" which is probs where the command was ran
Can I add buttons or a dropdown menu in Modal?
why does this say interaction failed everytime?
Video: https://streamable.com/ky19pi
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'coroutine' object has no attribute 'purge'
someone know this pls?
No one would know if you dont show code. just saying
Code? what are you trying to do?
@bot.command()
@commands.is_owner()
async def supp_tout(ctx: commands.Context):
await salon_auto_role.purge(limit=20)
await salon_esgi_role.purge(limit=20)
await salon_dev_role.purge(limit=20)
await salon_reglement.purge(limit=20)
await salon_tutoriel.purge(limit=20)
what could be the cause?
salon_auto_role = bot.fetch_channel(923316086483587085)
salon_esgi_role = bot.fetch_channel(974708754438303784)
salon_dev_role = bot.fetch_channel(975746758581846046)
salon_admin = bot.fetch_channel(923316087314067537)
salon_reglement = bot.fetch_channel(923316086483587083)
salon_tutoriel = bot.fetch_channel(976751453127454720)
?
gimme a sec to rewatch
oki
Does your console show any errors?
no
when you get an interaction failed it means your code simply hasnt sent a response back or it errored somewhere
it just say 'this interaction failed' but the whole things worked
have u watched the whole vid
yes?
hm
discord bug?
doubt, can you send some code pls
no errors at all + everything works fine
try adding ctx.defer() ?
ohh yes
or interaction.response.defer()
aight
it not help me
you could also be needing to send it via interaction.response.send_message(message)
or ctx.respond
otherwise you get the failed thing even tho it worked
gimme a sec
ty
fetch_channel is a coro
you need to await it
at the first of the callback?
like py async def callback(interaction): await interaction.response.defer()
mhm try
oki
i think you need to await fetch
so I need to place my fetch on a async def?
mhm
Example
test= await bot.fetch_channel(969580926885580801)
https://docs.pycord.dev/en/master/api.html?highlight=purge#discord.Client.fetch_channel
says here you needed to use await btw
but my channels arn't on a def
@desert dagger thx for telling me to try defer cuz it works :))
glad to see that worked 👍
whats your bot work like?
cause maybe just put them in the function and call function?
salon_auto_role = bot.fetch_channel(923316086483587085)
salon_esgi_role = bot.fetch_channel(974708754438303784)
salon_dev_role = bot.fetch_channel(975746758581846046)
salon_admin = bot.fetch_channel(923316087314067537)
salon_reglement = bot.fetch_channel(923316086483587083)
salon_tutoriel = bot.fetch_channel(976751453127454720)
@bot.command()
@commands.is_owner()
async def supp_tout(ctx: commands.Context):
await salon_auto_role.purge(limit=20)
await salon_esgi_role.purge(limit=20)
await salon_dev_role.purge(limit=20)
await salon_reglement.purge(limit=20)
await salon_tutoriel.purge(limit=20)
@bot.command()
@commands.is_owner()
async def prepare(ctx: commands.Context):
await salon_reglement.send(reglement1)
await salon_reglement.send(reglement2, view=auto_role.bouton_rules())
await salon_auto_role.send(embed=discord.Embed(title="Tu joues à quels jeux?", description="",color=0x00ff91), view=auto_role.bouton_jeu())
await salon_auto_role.send(embed=discord.Embed(title="Tu veux avoir acces à quels channels?", description="",color=0x00ff91), view=auto_role.bouton_salon())
await salon_auto_role.send(embed=discord.Embed(title="Es-tu à l'ESGI?", description="",color=0x00ff91), view=auto_role.bouton_esgi())
await salon_dev_role.send(embed=discord.Embed(title="Tu utilise quels languages?", description="",color=0x00ff91), view=auto_role.bouton_dev())
await salon_esgi_role.send(embed=discord.Embed(title="Tu es en Inital ou en Alternance?", description="⚠ Cette question ne concerne que les premières et deuxièmes années.",color=0x00ff91), view=auto_role.bouton_alt_ou_init())
await salon_esgi_role.send(embed=discord.Embed(title="Tu es en quelle année?", description="",color=0x00ff91), view=auto_role.menu_annee())
await salon_esgi_role.send(embed=discord.Embed(title="Tu es en quelle spé?", description="⚠ Cette question ne concerne que les troisièmes, quatrièmes et cinquièmes années.",color=0x00ff91), view=auto_role.menu_spe())
discord.errors.InteractionResponded: This interaction has already been responded to before
``` btw what could be the cause of this?
response.edit_message(message) multiple times?
seems like the error was caused by defer() when i add to my buttons callback lmao
ima remove it
mhm fair
just added defer() to the select menu callback then it worked
did say to test. no clue about your code xd
that's interesting
Can't bots have custom activity?
{emoji} {name}
no
Best thing i can say is global variables or create a function to process them and return
Bots dont have the custom activity we users have. At most is watching or streaming
I'm trying to setup group slash commands in a cog but all it does is this.
https://github.com/Pycord-Development/pycord/blob/v2.0.0-rc.1/examples/app_commands/slash_cog_groups.py
copy pasted this exactly
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_cog_groups.py at v2.0.0-rc.1 · Pycord-Development/pycord
assuming you mean the slash_cog_groups example, i dont see the problem?
that version of the code probably doesn't function properly though due to the CommandPermission usage
the fixed version is on my pr
thankss
##1389
i feel very dum :D
lmao ur good
same with trying bridge in cogs too. why do i keep on being stupid 😭
if I remember correctly I don't think bridge works correctly in cogs
yeah
bridge is a bit flawed rn, hopefully it'll get cleaned up before full 2.0.0 release
idk, depends on your use purposes
I went from a discord.js user to Pycord and i last used Python for just an AI chatbot project
Hey all, does anybody know how to make a command that adds / removes roles from a user. I’ve looked far and wide & can’t find anything.
Any help would work,
Thanks
yeah one sec
Ah thanks
imo dpy's new syntax for slash commands is weird but to each their own, their shouldn't be any significant differences
and also let me know the things I’ll need to import as well
any usage in specific
Ok
I like how pycord looks and a lot of people i know cant be asked to go back to discord.py and ppl feel danny might dip again
slash command to give and remove role right?
Yep
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/button_roles.py at master · Pycord-Development/pycord
this is a button but it works similar
Thanks
^^
one sec
await ctx.guild.create_role(name=role_name, color=color, reason=f'reason_here')
theres a good example somewhere on the docs
So will this give out a role of your choice?
alright letme just explain a few things
code creates role
gives it a color and audit logs will have reason
I’m talking about giving a user an existing role in the server already
do you want it to be any user or author
await member.add_roles(role) is all you really need to add role
Alright thank you!
well at least i explained how to create/remove roles , add and remove roles 😂 even tho the first two was useless
thanks
This is my problem
Hello ppl, i have a question, when using slash_command to tag a role, although it gets the right role it doesn't ping the people with the role as shown in the image https://i.imgur.com/NvCp0FV.png
Anyone knows why?
does the bot has perms to ping people?
application command responses are based on permissions for @ everyone iirc?
If i understand correctly, i did change the default permission to False for this command
Managed to fix it, for some reason in cog discord.AllowedMentions(roles) was set to false, i changed it to True and now it can ping roles
nice
Quick update, it suddenly stopped pinging roles again, i guess there's a limit to how many times the bot can ping a role?
there shouldnt be any
Weird then 
are u testing in a test server or production server?
test server
if its test server enable @ everyone to have perms to mention roles or have the role u want mentioned mentionable then try again
Ok, gonna test it
same lmao
very much fun ikr
well wasn’t for me, I gave up on js 😂
btw in the bot bit try adding allowed_mentions=AllowedMentions.all()
then see if that works. i realised you might have not had that
Didn't work, it's so weird because it was working with no problem and suddenly stop
might be cause of the update
I reverted all code till when i added the allowedmentions
And it's working again

Im so confused
Well it's working fine and dunno why 
help pls
slash command name must always be in lowercase ("ping" not "Ping")
can i get a quick example of what an .env should look like exactly?
Can someone help me?..
Is select in modal gonna be added soon?
I didn't get what you meant there
So my bot sends in the same twice, once once the channel is created to communicate with the player and then it sends in the reason for support again. But I want it to wait until the second message comes from the user means that it sends first only the confirmation and only after the second message sends message.content.
you know?
So here is my problem:
You want that second message to be sent when requested by someone?
Or you want to get rid of the message.content after the embed?
I don't know how to explain it, I'll just give it a try....
So the user sends once for example: Hi and after the Hi a ticket is created where the reason of the player is.
Then he sends for example: What's up and after the Whats up should first come message.content.
Do you understand?
Ahhh, you want the bot to wait for a message from the user?
Check out: https://docs.pycord.dev/en/master/api.html#discord.Client.wait_for
No 
oop-
message.content should only come after the second message from the user
For the second message from the user, don't you want the bot to wait for the user to send the second message?
means first the welcome message comes and then when the user sends a second message only message.content should come
But then only message.content should come
Yeah, the user sends second message, and then you get the message.content from the bot, correct?
yes 
This is it then.
Use wait_for()
what should he be waiting for?
From the example in the documentation, use the one where the bot waits for a "message" from the user, and then you send the message.content
msg = await client.wait_for('message', check=check)
The first example in the link I gave here @slender lintel
so?
def check(m):
return message.content
await bot.wait_for('message', check=check(message))
await channel.send(message.content)
just send the function, without calling it to check
in check, return m.author == message.author and m.channel == message.channel
Its working thanks! ❤️
But it sends the old message as soon as the user sends a second message, only after the third message it sends the correct content
Show me your code
def check(m):
return m.author == message.author and m.channel == message.channel
await bot.wait_for('message', check=check)
content_embeds = discord.Embed(description=f":HeartCute:› {message.content}", colour=0x51ff89)
content_embeds.set_author(name=f"{message.author.name}#{message.author.discriminator}",
icon_url=message.author.avatar.url)
await channel.send(embed=content_embeds)
This?
Is there any way to loop through all the options inside the application cmd(slash)?
I didn't get what's wrong?
Wait i send a screen
someone who can help me TwT
Welcome to coding
Example code?

when i enable intents that error comes Traceback (most recent call last):
File "/Users/janikschunemann/Development/Python/in-progress/Discord/main.py", line 12, in <module>
bot = discord.Bot(intents=discord.intents.all())
AttributeError: module 'discord' has no attribute 'intents'
hm
my code is bot = discord.Bot(intents=discord.intents.all())
You know?
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
How could I get the original message in a view, to edit it, on the on_timeout event
remove _url
i believe you cant really edit them after 15 minutes. You probably could fetch and edit them though
from discord.commands import SlashCommandGroup
ModuleNotFoundError: No module named 'discord.commands'
im not talking about that
I installed py-cord using pycharm's python package installer
hm
asset = author.avatar_url_as(size=128)``` this in pycord?
can you do pip list
and show me what py-cord version you're using
and?
could you somebody give me a full prewritten code on a slash command where you can give somebody roles
its 1.7.3
because i'm still really confused
you want author.avatar.url
gimme 3 minis
alright thanks
you'd want the altest
i want the profilpicture for a image
no, for a rank cmd
in any way it is discord.Member.avatar.url
Update to the latest pycord
author or targeted user
alr thanks
one sec yehe
pip install py-cord==2.0.0rc1
if top one fails
python -m pip install py-cord==2.0.0rc1
mhm
language is so hard to get.
you'd need one to check if you mention anyone or not then blocki
@desert dagger dm
Did you mean this screenshot where the message.content appears to be able the random message sent?
user = ctx.author or user
assuming youre passing user on your function
async def command(ctx, user: discord.Member)
then you can simply do
user.avatar.url
ok
What dark said
I am from Germany therefore the language but these are only information in the embed
anyone has an idea for is_owner thing on slash commands
Seems like the bot did send the message.content after you (message.author), sent a message
How can I fix it that the first message remains removed?
You want to remove the first message btw the bot or user?
I want the first message to be sent only once
Ahh, you're saying the first message is sent twice
Hey
oh lol
Lol
Yes
Its kinda just simple but alright
Ok
Can you show me the code from the part where you create the first embed till you send it?
Yes here
Just send the role cmd when your available
on_message
@bot.slash_command(name='give', description='Gives a user a role ')
async def give(ctx, role: discord.Role):
await ctx.author.add_roles(role,reason=f'{ctx.author}')
await ctx.respond(f'Role given: {role}')
There you go
Command gives the user running the command a role
Tysm
self._underlying.emoji = PartialEmoji.from_str(value)
AttributeError: 'Choice' object has no attribute '_underlying'
How do I add 🇦 as emoji for buttons
I get above error
I tried emoji=":regional_indicator_a:" and also emoji= \🇦
Question with Pycord, can we automatic sync?
not what im looking for
i want a moderator to use the command to give another user a role
so there is a list of members
you can pick from
& a list of roles you can pick from
@desert dagger
sorry
i need a role command exactly like dynos one
wait
one sec
something like this @desert dagger
user: discord.Option(discord.Member, "Enter a Username")
yes professional. Totally didnt start using Pycord 3 days ago 👍
but you still know what you're doing lol
getting this error now
anybody know why?
whats said in your console?
has no attribute "member"
show code
hm
How do I create a background task?
await member.add_roles(role, reason=f'{ctx.author}')
import discord
from discord.ext import commands
import os # default module
from dotenv import load_dotenv
load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[976234277123539017])
bot = commands.Bot(command_prefix="!")
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
@bot.command()
async def announce(ctx, title, *, message):
await ctx.send("**{}**\n{}".format(title, message))
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Unknown command.")
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
bot.run(os.getenv('TOKEN')) # run the bot with the token```
My bot isn’t responding to my ping or announce command?
no one come at me for being dumb btw please, I know basically nothing about py 😵💫
enable message intents
bot = discord.Bot(debug_guilds=[976234277123539017],intents=discord.Intents.all())
make sure you go to your https://discord.com/developers and enable message intent there too
Discord Developer Portal
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
still no response
I’m not sure but I’m assuming it’s something to do w the fact I’ve done bot = twice
idk what to change tho
I’m using the commands extension which is why I have bot = commands.Bot(command_prefix="!")
can you print all of your code?
Traceback (most recent call last):
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 1038, in on_connect
await self.sync_commands()
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 685, in sync_commands
await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 357, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
anyone pls help
import discord
from discord.ext import commands
import os # default module
from dotenv import load_dotenv
load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[976234277123539017],intents=discord.Intents.all())
bot = commands.Bot(command_prefix="!")
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
@bot.command()
async def announce(ctx, title, *, message):
await ctx.send("**{}**\n{}".format(title, message))
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Unknown command.")
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
bot.run(os.getenv('TOKEN')) # run the bot with the token
bot = discord.Bot(debug_guilds=[976234277123539017],intents=discord.Intents.all(),command_prefix="!")
make it one line
also how many servers is the bot in?
1
remove the debug_guilds part for now
followed all steps, still 0 response
have u went to https://discord.com/developers to enable it?
Discord Developer Portal
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
yep
hm
lmao what?
Good job :)
ty
ohh
ty for the help though
Anyone pls help
one question
anybody can help me?
i want to make a easy bot just to clear messages
but i dont know how
do you have any idea
in that case, you don't need the bot.wait_for()
I thought it's a command
Maybe, you should add the channel to a db or something to show that it is not new and don't have to repost the embed
which function fetch’s the bots ping?
it's the latency attribute
Could you give me an example of how to use it?
You mean, delete a webhook message? yes
i mean a webhook deleting a webhook message
like an "auto delete"
how do I send message to a specific channel using its Id?
how to get the message the user replyed to?
await ctx.channel.fetch_message(ctx.message.reference.message_id) if in command
pycord.dev is down?
channel = await ctx.guild.fetch_channel(your_channel_id) #getting channel by its id await channel.send("something") #sending message to channel
if in command
You can delete it after some time with delete_after=seconds in await Webhook.send function
How would i allow my bot to work in every server for slash commands, Instead of adding ID every time?
make it global
suggestion_group = SlashCommandGroup(name="suggestion", guild_ids=guilds, description="Suggestion commands, for suggesting")
class suggestion_modal(Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(InputText(label="Suggestion Topic", placeholder="Enter topic"))
self.add_item(
InputText(
label="Suggestion Content",
placeholder="Enter suggestion",
style=discord.InputTextStyle.long,
)
)
async def callback(self, interaction: discord.Interaction):
print("Hello")
await interaction.response.send_message(content="Suggestion was submitted.")
data = fetch_settings()
ch_id = data['settings']['suggestion-channel']
channel = self.bot.get_channel(ch_id)
embed = discord.Embed(title=f"{self.children[0].value}", description=f"{self.children[1].value}", color = discord.Color.green())
await channel.send(embed=embed)
@suggestion_group.command()
async def create(self, ctx):
data = fetch_settings()
ch_id = data['settings']['suggestion-channel']
isFound = utils.get(ctx.guild.channels, id=ch_id)
if isFound == None:
return await ctx.respond("Suggestion channel has not been setup correctly.")
modal = self.suggestion_modal(title="Suggestion Panel")
await ctx.send_modal(modal)
callback never gets called
for some reason
your callback is not in-line with the modal constructor
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 715, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 846, in exec_module
File "<frozen importlib._bootstrap_external>", line 983, in get_code
File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/container/cogs/moderation.py", line 9
@commands.command() # create a command
IndentationError: unexpected indent
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 27, in <module>
bot.load_extension(f'cogs.{cog}')
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 787, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.moderation' raised an error: IndentationError: unexpected indent (moderation.py, line 9)```
why am I getting this err?
self explanatory
not for me
fixed it now, ty
One message removed from a suspended account.
One message removed from a suspended account.
you can convert a unix time into a datetime.datetime object
with something like from_timestamp()
or smt
One message removed from a suspended account.
is it that bad if you make it an int
One message removed from a suspended account.
One message removed from a suspended account.
well, time.time() gives you the unix time
One message removed from a suspended account.
One message removed from a suspended account.
i think so
One message removed from a suspended account.
uh
idk
i think either date or run_date is a float and thats no good
does anyone know why when I have something like this my bot only sends the message if the message is sent by the bot. Example, I send "test" and nothing happens, I make a command to make bot say "test" and it works
hmm might be because it doesnt have messages.read scope but I can't give it that
fixed it
Is there anyway to use an if state so that if the message is sent by my bot it won't send the message?
can anyone help, im trying to make an embed and keep getting this
Embed fields only take, name, value, inline
Sip
what would be the best way to get a member from thier id in a slash command?
i thought ctx.guild.get_member(id) would work but it seems not
ah fetch_member works.
Can I make this wait press a button?
await self.bot.wait_for(...)
Is select in modal gonna be added soon?
we don't know, up to discord devs
no?
select in modal doesnt exist yet
discord hasnt implemented it yet
it'll definitely be added once discord adds it
its implemented...
where?
if you're talking about select menus inside of modals then no, it doesn't exist right now
yeah that's 100% just photoshop
tried sending the link to the discord devs server but link got deleted, you can go ask in there and they'll tell you its not implemented yet
????
u can go dpy server and see
how is this photoshop lmao
just checked their latest docs and it doesnt exist there either
and i have no idea tbh
id be shocked if discord just rolled it out with zero announcements
someone even made it
well shit if it does exist its the first im hearing of it and havent heard anything from discord abt it
maybe its on canary
idk prob
yeah seems like discord pulling some weird shit again
looks like it is on regular discord but unannounced, undocumented and potentially buggy according to one of the devs
it'll probably be implemented in pycord once the feature is actually documented
Hi, are the VoiceChannel's class text methods for Voice Text Chat Channels? Like is the bot able to send messages in there too at the moment, or not yet?
how to invoke a slash subcommand in other command
It has all methods of text channels except threads.
Like this: https://docs.pycord.dev/en/master/api.html#discord.VoiceChannel.send
hello this is my error: Ipy mportError: cannot import name 'PartialMessageable' from 'discord.channel' (/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/channel.py)
how can i fix it?
thx
There is no PartialMessageable in discord.channel.
You should import PartialMessageable from discord
Quick question, is it possible to build a thread object by passing an ID of an existing thread? discord.Thread({id}) or do I need more information than that. The bot will already be in that thread and have the server permissions to see that thread, even if archived or private. just making sure I don't need anything other than the ID
may i ask how?
from discord import PartialMessageable
ok thx
where shall i put this line
np
at the beginning of your code
but it still shows
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/channel.py)
python3.10/site-packages/discord/channel.py
it's trying to import from discord not py-cord
ok
wait. belay that. discord is still the package name. my bad
@info_group.command(name='guilds', description = 'send a file with all the guild id\'s')
async def show_guilds(self, ctx:ApplicationContext):
if ctx.user.id not in dev_ids:
await ctx.response.send_message("Sorry, only devs can do that!")
return
filee = open('guilds.txt', 'a+')
for guild in self.bot.guilds:
filee.write(f"{guild} - {guild.id} \n")
await ctx.response.send_message("Here is the guilds list", file = discord.File(filee), ephemeral = True)
filee.close()
Hi, i m trying to send a file, but it sends an empty file
and my file is not empty
it looks like an error in your site package. try updating pycord, and make sure you don't have any conflicting packages such as discord.py
ok
so what now? ```py
ModuleNotFoundError: No module named 'discord.enums'
No error traceback?
Traceback (most recent call last):
File "/Users/luke/PycharmProjects/pythonProject4/main.py", line 5, in <module>
from discord.ui import Button, View, Select
File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ui/__init__.py", line 12, in <module>
from .button import *
File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ui/button.py", line 32, in <module>
from ..components import Button as ButtonComponent
File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/components.py", line 41, in <module>
from .enums import ButtonStyle, ComponentType, InputTextStyle, try_enum
ModuleNotFoundError: No module named 'discord.enums'
nope
but i just used the path instead of the file var
and it worked
¯_(ツ)_/¯ all I can tell is that your package is messed up somehow. If it's upset that there are missing modules it may be that you need to uninstall and reinstall pycord
ah ok sad sad sad
yep
what module shall i use to import buttons and stuff?
Can I make this wait press a button?
await self.bot.wait_for(...)
discord.ui
couldnt y?
Everything on button done via callback
Traceback (most recent call last):
File "/Users/luke/PycharmProjects/pythonProject4/main.py", line 5, in <module>
from discord.ui import Button, View, Select
ModuleNotFoundError: No module named 'discord.ui'
what is happening?
Can I add buttons or a dropdown menu in Modal ?
I dont know, havent tried modal
Package Version
------------------ -----------
aiohttp 3.7.4.post0
aiosignal 1.2.0
async-timeout 3.0.1
attrs 21.4.0
beautifulsoup4 4.11.1
certifi 2021.10.8
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.0.12
DateTime 4.4
ffmpeg 1.4
frozenlist 1.3.0
humanfriendly 10.0
idna 3.3
multidict 6.0.2
names 0.3.0
Pillow 9.1.1
pip 22.1.2
py-cord 1.7.3
pycparser 2.21
PyNaCl 1.5.0
pytz 2022.1
requests 2.27.1
setuptools 57.0.0
six 1.16.0
soupsieve 2.3.2
typing_extensions 4.1.1
urllib3 1.26.9
wheel 0.36.2
wikipedia 1.4.0
yarl 1.7.2
youtube-dl 2021.12.17
zope.interface 5.4.0
please tell me which of the packages are making confusion
Update to rc
ui models are available in pycord 2.0
how do i check how many bots are in a guild?
Bots = [m for m in Guild.members if m.bot]
len(Bots)
thanks!
Do you know how can i create an invite link using a guild id?
b!rtfm pyc guildchannel.create_invite
Best matches for guildchannel.create_invite in pyc
Stack Overflow
I have this bot written in replit and discord.py and i cant make the leaderboard work. Idk why. I followed CodeWithSwastik tutorial ep 4 link -> https://www.youtube.com/watch?v=dI3_DWhfT8U
What ...
can someone help?
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 1038, in on_connect
await self.sync_commands()
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 685, in sync_commands
await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
File "C:\Users\Mridul Negi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 357, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
Somebody help, asking for 4th time TwT
nope
thats first time my bot is logging in
as per the error it seems happens when syncing commands
ig
git+https://github.com/Pycord-Development/pycord I have this
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
Ok could you send your code. please
sure
import discord
from discord.ext import commands
from discord.commands import permissions,Option
import psycopg2
intents = discord.Intents().all()
intents.members = True
intents.message_content=True
prefix = 'p!'
bot = commands.Bot(command_prefix=prefix,intents=intents,debug_guilds=[981533402429812746],activity=discord.Activity(type=discord.ActivityType.listening, name=f"voting"),status=discord.Status.dnd)
bot.remove_command("help")
con = psycopg2.connect('postgres://grunnwgnhjobes:441b8447e23c7b73b91140f7d6c5997a68da1ab6eb36016a7cbd5e6ef9101cae@ec2-35-169-188-58.compute-1.amazonaws.com:5432/d815dnp34od7j4', sslmode='require')
query = con.cursor()
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
bot.load_extension("cogs.voting")
oh wait
there is an unnecessary import
@worthy basin here
Sorry you will have to wait 10-20 min I'm not on PC so I can't see the whole file.
ok
btw will interaction just failed if around 100 people uses the button together
whenever someone clicks, the label on button changes to number of times clicked
A few things I can input. It make sure all of your command names are valid and also make sure you invited your bot with the slash commands permission.
Can't remember what is is called rn
applications.commands scope
?
Yeah
Oops responded to the wrong message
lol
I meant yeah to this
Already invited my bot with this scope
The error does no harm till now
code works just fine
No but yes, if you had a super computer it wouldn't but your bot is trying to process 100 requests at the same time. So it will queue them up and depending on how fast the callback is the ones that gete queued to the end might pass there 3 seconds.
I am using defer, ig it shouldnt cause interaction error
Well if you think of it it might take over 3 seconds to receive the butten press and send defer (and wait for response from discord?) 100 times. But that is only if it was the same time. I would imagine that if its 100 people in a minute it would be able to handel it.
my bot will surely crash then 💀
What specs for the server you prefer for that amount of traffic?
I always hosted free before for small projects 💀
worked lol
Ngl my bot is in 2 servers with like 5 people who have ever used cuz its in development. But there is some cheap hosing out there. I think the host I use charges $0.75 for the cheapest bot hosting.
So I got another quick question, this one about Views. I'm seeing in the guide that you can update the view with something akin to await self.message.edit() but looking at the documentation, it doesn't look like a View has any property message. Is this the proper way to edit a View's message? the exact thing I'm trying to accomplish is a View that cleans itself via deletion upon timeout.
current implementation is
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=10)
async def on_timeout(self):
await self.clean_up()
async def clean_up(self):
await self.message.delete()
that's the basics anyway. theres other stuff there but this is the part I really need help with
So a view is attached to a message. You will need to edit the message that contains the View. In your example clearing it would be Message.edit(view=None) let me find how to get the message from the view
hmm. I would love to be able to send the message to the view but the message hasn't been created by that point 😅
There is always a message when a view is sent even if there is no text
You could pass the message as an argument to MyView
that's the thing. If I use ctx.respond then the message hasn't been created when I'm trying to inject it
Im not getting what you mean, sorry?
define the message attr youurself
on your constructor
class MyView(discord.ui.View):
def __init__(self, msg: discord.Message = None):
self.message = msg
ctx.respond can take in a string and a views parameter. if I use it like that then the message hasn't been created by the time I'm trying to pass it into the view. theres no reference to it yet
Ah ok, i see it now
store the respond to var
thing = await ctx.respond('mymessage' views=MyVew(thing)) just wont work
the set your message attr to that message var
I'd like to send the view clean without having to edit it to attach the view
rsp = ctx.respond(view=view)
SubView.message = resp
well, attaching the view isn't that bad actually. I could look into doing that
this would work as well
I will ask to see if there is a way to more easily get the message a view is attached to.
there is the possibility of a race condition because more than one thing calls the clanup method. but it should be okay
the SubVew.message thing doesn't work because it's an instance variable I'd be changing. dangerous to make it and change a class variable. I'm going to have multiple of these views and if I pass it to ctx.respond(views=MyView) the view itself is an anonymous view. I guess I could instance it before hand
InstView = MyView()
resp = ctx.respond(views=InstView)
InstView.message = resp```
Actually that's probably clean enough for what I need done
Great, sorry I was not more help.
My only worry is the race condition, but with the way it's programmed it will persist if the instance doesn't have a message when clean_up is called
First one try re-installing py-cord with 2.0rc1
Second it is ephemeral not hidden
From the breaking change log
Attributes that returned Asset are renamed, e.g. attributes ending with _url (i.e. avatar_url) are changed to avatar.url. User.avatar returns None in case the default avatar is used.
ctx.defer() still works
how can i add options in a slash command? like the user has to select from to values in the command
How would I reload a file (Not a Cog)
Ex of what I've tried:
import randomFolder.FileName # Tried to reload it like this "reload(randomFolder.FileName)" and "reload(randomFolder)"
# Tried reloading the module thinking it would reload the folder in general or the file :/
@client.command()
async def reloadFile(ctx, ext: str):
await reload(ext) # Tried using pythons reload function :/
await ctx.send(f"Reload {ext}")
Didn't work, ofc.
What I'm trying to do:
Reload a file/ or folder without closing and reopening a new terminal.
You can use dropdowns, emojis, buttons, etc... import discord.ui https://github.com/Pycord-Development/pycord/tree/master/examples/views
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/examples/views at master · Pycord-Development/pycord
I have this bot written in replit and discord.py and i cant make the leaderboard work. Idk why. I followed CodeWithSwastik tutorial ep 4 link -> https://www.youtube.com/watch?v=dI3_DWhfT8U
What i want is to make a leaderboard which will show the top 5 people with the most money
I use json file as database (ik its not recomended but ik how to use it so i use it)
json example for one person ->
"coins": 12253,
"job": "none",
"expirience": 0,
"inventory": [],
"bank": 10000
}
The code for the leaderboard command ->
@bot.command(aliases=['lb'])
async def leaderboard(ctx, pepol_to_show = 5):
data = await get_bank_data()
lb = {}
total = []
for user in data:
name = int(user)
total_amount = data[user]["coins"] + data[user]["bank"]
lb[total_amount] = name
total.append(total_amount)
total = sorted(total,reverse=True)
em4 = discord.Embed(title = f"Top {pepol_to_show} Richest people", description = "Who has the most potatoes (Wallet + Bank)", color = discord.Colour.red())
index = 1
for amt in total:
id_ = lb[amt]
member = bot.get_usser(id_)
name = member.name
em4.add_field(name = f"{index}. {name}", value = f"{amt}", inline = False)
if index == pepol_to_show:
break
else:
index += 1
await ctx.reply(embed=em4)
async def get_bank_data():
with open("users.json", "r") as f:
data = json.load(f)
return data
When i run the lb command nothing is sent in discord and i get 0 errors. No idea why
Why doesnt this work? What do i need to do to fix it?
Is the cmd in a cog?
no
If so could probably be miss indention
i want something more like this ```py
async def set(self, interaction:discord.Interaction, channel:discord.TextChannel, type:Literal['Auction Log','Blacklist Log','Open Ticket']=None):
but this is d.py not pycord
i'm getting no module named discord i tried everything its not working 😢 my other bots work fine aswell
with d.py
i want it in pycord xD
do they work the same?
^
oh oki
They look just alike so, I'm pretty sure they work the same.
ModuleNotFoundError: No module named 'discord'
instead of pip install pycord try py-cord @ git+https://github.com/Pycord-Development/pycord@a518aaa5c02d6d0e23685f148a293d4f11f0c33c
kinda the same thing with d.py
Do you have an oncommand error function in any of ur files?
if so remove it and see if the cmd returns an error
import discord
from discord.ext import commands
from discord.ui import View
from discord.ui import Select
@client.slash_command(guild_ids = serverID)
async def test(self, ctx):
view = discord.ui.View()
TestButton = discord.ui.Button(
label="Button",
style=discord.ButtonStyle.red,
emoji="❎"
)
async def se_callback(interation):
await interation.send_message(view=view)
TestButton.callback = se_callback
view.add_item(TestButton)
await ctx.interaction.response.send_message(view=view)
try sum like that.
could put an embed first if needed.
I don't do slash commands so I wouldn't be much help :/ I prefer regular chat cmds 😭
still get the error, im on python 3.7 but i tried 3.6-3.8 and none worked
it's fine, thanks for trying
np
You could try look at this: https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_options.py
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_options.py at master · Pycord-Development/pycord
well
found it, i need Option, and OptionChoice
I had the error once but forgot how I fixed it.
well idk then, sorry mate. :/
i had it too
pip install discord
ok
pip install discord==1.7.3 -- Make sure to put the latest version of discord.py
@craggy linden
@info_group.command(name='blacklist', description = 'blacklist commands')
async def blacklist(self, ctx:ApplicationContext, action:discord.Option(str, 'test', choices = [discord.OptionChoice(name="+", value="+"),discord.OptionChoice(name="-", value="-")])):
await ctx.send('test')
this worked, in case you want to use something similar
Eh, Ima stick to chat commands.
Instead of slash cmds
since I can just do async(ctx, value1, value2, value3=None): etc...
this is the error
Ignoring exception in command leaderboard:
Traceback (most recent call last):
File "/home/runner/DiscordPotatoBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 406, in leaderboard
name = member.name
AttributeError: 'NoneType' object has no attribute 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/DiscordPotatoBot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/DiscordPotatoBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/runner/DiscordPotatoBot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
member.name I'm guessing is the error
give me a min
pycord? or d.py
Did you do pip install discord or pip install pycord
This is pycord. Not discord.py
try member_name
i did pip install discord.py
That's not how it works
yeah
Eh just a suggestion.
Yeah OK. This is pycord.
A wrong suggestion.
what do i need to do then?
kk
This is pycord server, but this channel is for helping in "general".
So it doesn't matter what he uses he can still receive help, since pycord and discord.py are very similar.
try ctx.author.name or user.name
You have no context on the command and you're telling him to use ctx.author.name?
Are your blind?
If I'm not mistaken async def leaderboard(ctx, pepol_to_show = 5): ctx does stand for Context
What if he's getting users and then getting their name?... it is a leaderboard command
If so then he can simply get the names from the json file.
anyone has an idea why the git ignore file is in my commit list?
There's no name stored. He's storing the ID'S and then getting the user. The user is not in the bot's cache so it returns None.
He could simply try and get the name from the ID or just start logging names.
He alr told me in dms he's gonna try logging usernames.
So problem solved.
Logging names is completely inefficient.
I don't see how it's "inefficient"
He is getting the name from the ID, but he's looking in the bot's cache.
What if the user changes their name? Users with the same name? It's completely inefficient storing a name when you have unique ID'S.
Well then, like I said he could just use the users ID to get the Username.
<@ID> Since it would be more "efficient"
You realise mention ≠ username.
I don't think a person would get mentioned/pinged if it was placed in an embed.
Which he is doing.
.gitignore is a file, but file in .gitignore is a file that need to be ignored
This is not the dpy support server. dpy and pycord work differently we cannot help you.
Not really, most features are compatible.
ModuleNotFoundError: No module named 'discord.utils'```
@worthy basin this forces me to install pip install discord
No, if you have pycord installed it should not. You might have to restart your IDE for it to recognize it.
okk
2.0 is almost completely different
If you look at discord.py github and pycord github a lot of stuff is fairly the same.
this guy smh
Take the examples section as an example.
# Pycord #
import asyncio
import discord
class MyClient(discord.Client):
async def on_ready(self):
print(f"Logged in as {self.user} (ID: {self.user.id})")
print("------")
async def on_message(self, message):
if message.content.startswith("!editme"):
msg = await message.channel.send("10")
await asyncio.sleep(3.0)
await msg.edit(content="40")
async def on_message_edit(self, before, after):
msg = f"**{before.author}** edited their message:\n{before.content} -> {after.content}"
await before.channel.send(msg)
client = MyClient()
client.run("token")
# Discord.py #
# This example requires the 'message_content' privileged intent to function.
import discord
import asyncio
class MyClient(discord.Client):
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
async def on_message(self, message):
if message.content.startswith('!editme'):
msg = await message.channel.send('10')
await asyncio.sleep(3.0)
await msg.edit(content='40')
async def on_message_edit(self, before, after):
msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
await before.channel.send(msg)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run('token')
Completely the same.
I mean, I know it's just a fork, but they could try making it like nextcord.
not when you *going into pages
If its only kind of the same we won't be able to help. We also don't want to mislead pycord users if they see a dpy user getting help for a similar issue and copy it.
They have there own support server and you will get better help for dpy there anyway
How do a make a Server Roles list but with reaction pages?
So I already know how to make pages but the problem is when I use ctx.guild.roles it sends the same embed 50 times instead of making pages
Photoshop bud, it’s not released
bud how about going to dpy server and see it for urself lmao
They didn’t even announce it in the discord devs server, and they would
i suggest you go dpy server and check it out urself instead of saying more here
.
They aren’t "released" but in development, so the Pycord devs may not know about them but I don’t know what they know.
So they aren’t added to Pycord
Hope they add it soon tho
You might get better answers here
Yes I know jeez
Whenever i start my bot i get a ton of errors,
DEBUG:discord.client:Dispatching event member_update
DEBUG:discord.gateway:Keeping shard ID None websocket alive with sequence 8.
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
DEBUG:discord.gateway:Keeping shard ID None websocket alive with sequence 8.
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
``` then its got a ton if infomation about this one server above it
like guild id, role info all that its really weird

why does import discord.ext not work?
cannot import name 'commands' from 'discord.ext'
I have pycord installed
Please help, urgent.
you imported logging?
yeah
thats normal
It isnt an error?
nah its not
Oh okay, Thanks
any help?
Also, Is it possible to have owner only commands but also have it so it needs admin perms?
So i can have a command for myself only and admins
I keep getting these, Is this an error?
as of perms 2, gues you cant use owner perms anymore, so you gotta write the statement under the command callback
alr
seeing DEBUG: it is not an error
If its an error, Would i get like ERROR:
do you even know about logging?
yes i guess
okay
Lol i just added it because i thought it would be important for errors ect
god i fucking hate this
try reinstall everything
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
if ctx.content.startswith("?joke"):
AttributeError: 'Context' object has no attribute 'content'
how to fix th is
when i was using dpy i used to have message.content.startswith
do i just do message.startswith?
ctx.message.content
b!rtfm pyc context
Best matches for context in pyc
b!rtfm pyc commands.context
Best matches for commands.context in pyc
discord.commands.context.ApplicationContext
discord.commands.context.AutocompleteContext
discord.ext.commands.Context
discord.ext.commands.Context.args
discord.ext.commands.Context.author
discord.ext.commands.Context.bot
discord.ext.commands.Context.can_send
discord.ext.commands.Context.channel
discord.ext.commands.Context.clean_prefix
discord.ext.commands.Context.cog
how to do this (it is in dutch)
remove str
and double quote
then add +
yourvar = var1 + var2
print(sys.version)
import discord
from discord.ui import Button
from discord.ext import commands
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
bot = discord.Bot(debug_guilds=[965533467557371944,933803468815204372,964126154774679582])
bot = discord.Bot()
bot = commands.Bot(command_prefix='!')
async def stats(ctx):
ctx = ', '.join(ctx)
await ctx.send('My ping is {bot.latency}')```
My !stats command isnt doing anything
the thing is that i have to do 1 - 2
use f string then convert input var to int
e
how can make slash command lol
i currently have bot.command() but its not showing up when i type /
Remove this
ctx = ', '.join(ctx)
@bot.slash_command(name="(name)", description="e"
await def (name) (ctx)
ctx.respond('hi')
theres a basic one
ty
ty but can you maybe give a example beacause i don't really understand it
should i use respond instead of send?
whats the difference
GitHub
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master · Pycord-Development/pycord
look over this
Sori sori
YourVar = int(inputvar1) - int(inputvar2)
Actually doesnt need f string lel
bruh just tell me
difference between respond and send
u dont need to link to the docs for a simple question
Respond = reply
Send = just sending the message to channel
so respond is just send but with referenace = ctx.message
ty very much
ok
bit rude, he was jsut tryna help you
dont think its rudea
and lets be real linking the docs doesnt help much
i could have just searched
either way
why are embeds not the same in pycord
TypeError: Expected discord.Colour, int, or Embed.Empty but received NoneType instead.
i get this error
for this
embedvar = discord.Embed(
colour = ctx.message.author.accent_color
)
still dosent send a message after !stats
The docs were made to help
ok
Change it to Embed = discord.Embed(title="(Your Title)", Description="(Put your embed text here", Color=color=discord.Color.blue())
Guess you'll have to enable message intent
Im pretty sure it already is enabled
on discord dev portal right?
Both
I mean on what is it called? Bot class?
yeah
bot.intents = discord.intents.default()
If i wanted all intents, Would i just change default to all
Yes i guess
? AttributeError: 'Context' object has no attribute 'respond'?
b!rtfm pyc intents
ctx.respond aint working lol
Thanks
Show the code bru
Only for app command
Use reply for prefix comand
yea reply is fine
you're probably getting commands.Context which doesn't have respond
do you have application.commands permissions from the dev portal?
Make sure you invite your bot with the correct scopes as said above
It needs application.commands, once thats added re invite it
how do i enable application.commands?
With all intent, It still wont work
Go to discord dev portal and select your bot, Then go to oauth2 then its there
thats different
Ah wait, you defined bot var too much
Eh
It should not matter ig?
Try use either one from discord or commands 
wym?
use either
bot = commands.bot(...)
or
bot = discord.bot(...)
is your code that exact line?
if so you havent set intents and you need those
print(sys.version)
import discord
from discord.ui import Button
from discord.ext import commands
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
bot = discord.Bot(debug_guilds=[965533467557371944,933803468815204372,964126154774679582])
bot = discord.Bot()
bot = discord.Intents.all()
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
print('Connected to bot: {}'.format(bot.user.name))
print('Bot ID: {}'.format(bot.user.id))```
async def stats(ctx):
await ctx.respond('My ping is {bot.latency}')
remove all this:
bot = discord.Bot(debug_guilds=[965533467557371944,933803468815204372,964126154774679582])
bot = discord.Bot()
bot = discord.Intents.all()
bot = commands.Bot(command_prefix='!')
and replace with this
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all(), debug_guilds=[965533467557371944,933803468815204372,964126154774679582])
or
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', debug_guilds=[965533467557371944,933803468815204372,964126154774679582], intents=intents)
I need to keep the debug guilds part for any slash commands ive got dont i?
yeah but you can define that inside of commands.Bot
okay
so i add debug guilds=[(guild ids)] right after the intents part
yeah i see
u edited
ty
Is there an event emitter? like a way to test an event
alright
sort of but its not something that'd be very easy to do, it's probably better to just trigger the event manually instead of through code
is there a way to let the bot reply to the slash command with a reference
ie it is highlited in yellow as if it was replying
normally
i guess i can just kick a bot to simulate a member joining
i found bot.Dispatch
can you make a menu in pycord slash commands? so that you make e.g. /role and there can say add or remove?
you can try but i have no idea if you can simulate something like that through code
you can just make it an option? to either add or remove
but how can i do that you can choose between two options?
{bot.latency}, Where can i find all the infomation related to stuff related to bot latency ect, Its wrong but i dont know the right one
docs?
b!rtfm pyc latency
Yeah i knew docs just didnt know what part lol
^^^
also why does this not work
color = ctx.message.author.accent_color
this is in an embed btw
I literally told you why
uhh
no u told me how to fix it not why
Change it to Embed = discord.Embed(title="(Your Title)", Description="(Put your embed text here", Color=color=discord.Color.blue())
bruh
because its optional
Hes trying to change the color of his embed according to his code
it doesnt always return something
ah i see
plus you have to fetch the user first to get it if it even exists
background color of a user
i see
