#General Help
1 messages · Page 19 of 1
@commands.cooldown(1,20, commands.BucketType.user)
async def say(self, ctx, message):
if ctx.author.guild_permissions.read_messages:
await ctx.respond(message)
await ctx.respond('I have sent this.', ephemeral=True)``` Why do i get command not found? I am moving to normal commands
oh that's odd
Have a database that stores prefixes per guild and run a function that returns the prefix
apparently discord.ThreadOption also exists, but if discord.Thread is working in discord.Option then fair enough
because you can't send an ephemeral message through a normal command?
You can’t respond? Those are for interactions. Use await ctx.send or reply
ephemerals only work with interactions (application or otherwise)
Oh okay, Sorry i have worked with slash commands not prefixed
and just using discord.Thread will only list public threads, not private or news threads
ctx.respond in this cause would reply to the command that was send.
Atleast that's the case with the bridge ctx, not sure if the normal ctx was updated too 🤔
Well ye for bridge
Why the hell would you return to prefixed commands? They are far inferior to slash commands 🤔
ehh to each their own, slash commands are pretty good now and i usually opt for them but people still have their preferences
I can't think of a reason to go for prefixed, now that we have permissions and backend v2.
now if your server has neither of those (which should be a very tiny amount of servers atm) I would say sure, go for prefixed. But otherwise I can't think of a reason why 🤔
Whats the difference? Not much.
Prefixed commands look way cooler
What javascript lib is the most similar to pycord/d.py/d.py forks?
Is it possible to make embed field copy?
I only know discord.js :P
May i ask, Whats the actual difference other than obviously slash commands is the way to go if you plan for your bot to be public and be verified and i dont.
The cool extra features?
:>
Like ephemerals, modals, user commands, message commands
it's definitely more user-friendly
maybe glance through https://libs.advaith.io/#javascript
Compares Discord libraries and their support of new API features
people can do a / and see all your commands.
Alright, Thanks to dust and yourself
Primarily that because application commands are stored on Discord's end, there's a lot more that can be done with them to make it easy on the user (type checking, argument parsing etc.)
The bot still needs to process the command logic, but everything before that is done beforehand; whereas with prefixed commands, the bot only knows about the command after the user sends the message
they still have some ways to go but they're certainly much better than when they were first introduced and received with disdain
And the slash command suggestion thing they added recently is also helping a great deal.
where it will suggest a slash command, with pretty much any known commonly used prefix.
so !monster, on my server would say:
Which is helping people to transition too 🙂
how can add to it embed field in this list? I will be grateful.
you can do this with variables, but you can also add .add_field(...) at the end of each embed (however, you can only add one field)
if filename.endswith('.py'):
bot.load_extension(F'commands.{filename[:-3]}')
for filename in os.listdir('Embeds'):
if filename.endswith('.py'):
bot.load_extension(F'Events.{filename[:-3]}')``` Trying to connect some folders with my main file, Its the correct names but i get 'No module named Events'
Nevermind i just named it wrong (another one i was going to add) but now i get extenstion.rules is already loaded
How would i unload it?
guess
bot.unload_extension(f"Embeds.{Embeds}")?
xD
?
reread your code
bot.unload_extension(F"Embeds.{filename[:-3]}") changed to this, no errors
i re read xD
I ran the above code to unload my cog, then loaded it and it says its already loaded??
@crimson coral
Ive unloaded the cog, I dont see the issue
how to send message when the bot gets pinged
async def on_message(message):
if bot.user in message.mentions:
Welcome=discord.Embed(title="Felbot",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here!",color=discord.Color.blue())
Welcome.set_author(name="FelBot", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="https://i.ibb.co/tz7VQJw/felb.jpg")
await message.channel.send(embed=Welcome)```
Heres an example of mine :)
Anyone?
if its already loaded
its already loaded
yeah, but ive unloaded it
try again
Its unloaded, Loaded again and same errror
hm
I have tried multiple times
that is weird it shouldnt be loaded at all
and you are unloading it again
even though it isnt loaded
bot.unload_extension(F"Embeds.{filename[:-3]}") to unload right? (when runnign this i get told, its not loaded but when i load same error as before)
well it already isnt loaded
you never loaded it before
and then you are telling it to unload it
even though it isnt even loaded
Yeah but when i try to load it i get the error
saying i have loaded it
is rules.py a cog?
or is it just to store variables
Its a cog yeah, Its a slash command that would then send a embed
You want me to update my github and you can see it there?
there is also another thing wrong with it
you are unloading the cog
every single
time
you load a cog in your commands directory
Yeah but ive now got a seperate folder called Embeds and Rules.py inside it
then do it outside of the loop
wym?
or do something like
directories = ["./commands", "./Embeds"]
for directory in directories:
for filename in os.listdir(directory):
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")```
Thanks
I don't see a point in unloading something that is already unloaded just keep it loaded
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\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 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\jackd\Documents\Felbcord Py\commands\say.py", line 2, in <module>
from discord.ext import slash_command
ImportError: cannot import name 'slash_command' from 'discord.ext' (unknown location)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 12, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension self._load_from_module_spec(spec, name)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'commands.say' raised an error: ImportError: cannot import name 'slash_command' from 'discord.ext' (unknown location)``` (It worked before i changed this)
uh no
from discord.commands import slash_command
or from discord import slash_command im pretty sure
this never worked even before you changed it. This is because your other cog never was loaded
Say cog was loaded, Has been for ages
AttributeError: module 'discord.commands' has no attribute 'Bot'```
...
from discord.ext import commands
bru im dumb, I had that but changed it to from discord for some reason
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\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 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\jackd\Documents\Felbcord Py\commands\say.py", line 2, in <module>
from discord.ext import slash_command
ImportError: cannot import name 'slash_command' from 'discord.ext' (unknown location)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 13, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension self._load_from_module_spec(spec, name)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'commands.say' raised an error: ImportError: cannot import name 'slash_command' from 'discord.ext' (unknown location)```
I wanted to organize my code with cogs but...
discord.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ClientException: Cog named 'events' already loaded
Im basicly having this same error :/
look at which file it tells you to change
well it was my orginal one*
show code
cogs = []
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
cogs.append("cogs." + filename[:-3])
print(cogs)
if __name__ == "__main__":
for cog in cogs:
client.load_extension(cog)
I changed from discord.ext to from discord but got this
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 13, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 785, in load_extension raise errors.ExtensionNotFound(name)
discord.errors.ExtensionNotFound: Extension 'commands.__pycach' could not be found.```
have it print out py f"{directory[2:]}.{filename[:-3]}" instead of loading it
cause i might have my indexing wrong
so print(f"{directory[2:]}.{filename[:-3]}")
or am i being stupid
mhm
Yay it started
did it load the extensions?
cause you have it as print rn
Ima check if they work
def load_extensions():
for filename in ["cogs"]:
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")
if __name__ == "__main__":
load_extensions()``` Im not sure how to fix it from the code you provide cause it looks right but maybe try this?
Nope :(
@slender lintel
dont ping
what does it print out when you printed it
All of the files in the directorys
Also did you guys jsut load them somewhere else and then loaded them again or something?
Sorry im quite inpatient
I tried to load another folder with cogs
As i have commands folder w my cogs that used to work and my embeds folder
w a cog
can you show full code please
My full main file?
like push to a github or something
yeah
or send in file
Sure, Ive got one just need to update it
gimme a sec
@graceful robin can you send full code in a file please i want to see what you guys did.
its ok i can read it
upload to github
he deleted his msg lol
Hows it going to take time?? It takes like 10s
Oh okay, I thought you said you had one already lol
I used the website 😳
are you still getting the error that it is still loaded? or is it a different error
This one
Lol
OHHH
ok i didnt full read it
?
Oh
well ik what went wrong
for directory in directories:
for filename in os.listdir(directory):
if filename.endswith(".py"):
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")```
forgot to check if it was an actual python file
Oh yeah
i made it public for now, i uploaded a zip file
I'll add that in a min
invalidate your token real quick please
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1042, in on_connect
await self.sync_commands()
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 629, in sync_commands
registered_commands = await self.register_commands(
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 529, in register_commands
registered = await register("bulk", data, _log=False)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 7: Application command names must be unique``` seperate issue now, It wont even tell me what file has the same name
you didn't delete it...
Yeah if hes leaked it 💀 reset it
delete what?
was not talking to you
just saying he didnt delete his token frmo the files
ik
oh sorry
i reset it
k
e
pretty sure that happened when your commands are synced twice
idk how to fix that
Is it fixable for sure or
¯_(ツ)_/¯
Do any others know, as of now i cant even use commands
How is that possible
i dont know
unless you do client.sync_commands() twice maybe?
I dont have it once
Same
Are you also getting this error?
I think that I have a different one
yeah sorry i have 0 clue why yours dont work, it should
I get this error message
Maybe I have to wait till Discord updates the commands or smh idk
I'll wait
what is the button click event? on_button_click(payload)?
there are none
except for on_interaction(interaction)
Hmm the docs say that
This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the View instead as it provides a nicer user experience
but do callbacks work after restarting the bot? for example 1) user uses a command $menu to show menu, 2) bot saves the menu id to database, 3) bot restarts and loads id from database, 4) user clicks the button
#986332926616678410 pls anyone
can there exist two exactly same message ids on discord? if yes, how to differentiate between them in my database?
discord ids are generated from a timestamp so I doubt that
(I think they're generated from a timestamp)
hmm, then what if two people on two unrelated servers post message on the exact same time
help pls after i used a slash command twice the command doesn't works anymore
error?
wait a min
user IDs are generated by timestamp, proccess ID and some other things. I dont think it is possible to ever get the same message ID
Are you able to help me in #986332926616678410 ? I have tried so much.
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 126, in wrapped
ret = await coro(arg)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "Desktop/public-main/cogs/fun/coinflip-fun.py", line 13, in coinflip
await ctx.respond(random.choice(coinflip))
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/context.py", line 227, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 686, in send_message
await self._locked_response(
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 933, in _locked_response
await coro
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 357, in invoke
await injected(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
code?
import discord
from discord import Embed
from discord.ext import commands
class Coinflip(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.command()
async def coinflip(self,ctx):
coinflip = ["Head", "Number"]
await ctx.respond(random.choice(coinflip))
def setup(bot):
bot.add_cog(Coinflip(bot))```
i dont know hwo to type it cause im a mac user
3 ` at the start and end
to make it into a code block
???
```like this```
The issue here is that you're using ctx.respond on a prefixed command
Use ctx.send or ctx.reply instead
hey guys
whenever i make a command
they never work in my discord
so even if its 100% correct the bot doesnt respond
prefixed command?
yeah
What's your pycord version?
are you providing your bot the required intents for prefixed commands to function?
idek
only just got back into discord dev
you need messages and message_content intents
so forgot most things
Do you have the message_content intent set to true?
where would i do this
you need to acquire a Intents object either by just instantiating it normally or by using one of the three factory methods
ok
when you say using a prefixed command
u mean this
dont you?
yes
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *,reason=None):
await member.ban(reason=reason)
await ctx.send(f'Banned {member.mention}')```
this command is correct yes?
intents = discord.Intents(messages=True,message_content=True)
bot = commands.Bot(command_prefix="!",intents=intents)
This is how you put intents on your bot
ty
this code is correct
isnt it
it is
yeah nice
^this, also don't use discord.Intents.all() and only set to true the ones that you're gonna use
you're gonna have to add them depending on events or listeners you have
for example, on_raw_reaction_add would require the reactions intent
Hey @worthy basin My thread randomly closed, whys that
do i need to change the inactivity
auto archival
oh alr
Why he`s give me 1 Online Member?
count = len([m for m in guild.members if not m.bot if m.status != discord.Status.offline])
Cache?
maybe instead of having two if join them with an and
Ohh I found the error I restarted the bot too quickly just saw it updated thanks anyway
yeah was gonna say
Btw when the Bot sends in DM
is it
user.send(content)
and what does the user have to be?
as in User ID
i have a next problem i have read the docs but i dont know whats wrong ?
@bot.slash_command()
async def choice_test(ctx, reason: OptionChoice(name="Reason")):
await ctx.respond(f"Test {reason}")
Error:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\main.py", line 70, in <module>
async def choice_test(ctx, reason: OptionChoice(name="Reason")):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\bot.py", line 914, in decorator
result = command(**kwargs)(func)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\commands\core.py", line 1551, in decorator
return cls(func, **attrs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\commands\core.py", line 628, in __init__
self.options: List[Option] = self._parse_options(params)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\commands\core.py", line 676, in _parse_options
option = Option(option, "No description provided")
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\commands\options.py", line 132, in __init__
_type = SlashCommandOptionType.from_datatype(input_type)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Bots\venv\lib\site-packages\discord\enums.py", line 660, in from_datatype
if datatype.__name__ in ["Member", "User"]:
AttributeError: 'OptionChoice' object has no attribute '__name__'
you should be using Option, not OptionChoice
but i want this
you use OptionChoices inside of Options
How am I supposed to do it then?
(these use the decorators, but the arguments work the same as using discord.Option)
i must me login in github?
just in case someone saw this and forgot to message back, but I'll try some other alternatives
nvm figured it out
@slender lintel
@bot.slash_command()
opt = [discord.OptionChoice(name='name of the option', value='option_value'),discord.OptionChoice(name='name of the option2', value='option_value2')]
async def choice_test(ctx, reason: Option(str, "reason", options=opt):
if reason == "option_value"
await ctx.respond(f"Test {reason}")
discord.OptionChoice can be OptionChoice if you import it
I have already thanks
yeah just showing you that way if you find it easier
👍
just updated pycord and now my bot has completly stopped responding to connands
any fixes?
or a way to revert back?
Hmmm, When making a bot with replit, Do i delete all thats already in .replit folder? Or just paste
language="python3"
run = """
pip install py-cord
python main.py
"""
[packager]
ignoredPackages=["discord.py", "discord"]
don't use replit, but if you have to, fork your replit from one of your older projects that doesn't have .replit and nix then do that
I dont have an older replit that actually worked
How can i find them?
?tag replit
Read this to find out how you can install Pycord in replit - https://namantech.me/pycord/installation/#replit
How to install the Py-cord library - Pycord Guide
?tag norepl
Why NOT to use Repl as a hosting platform
You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.
- The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
- You'll need a web server alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
- Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
IMPORTATNT
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.
@pale igloo just some stuff
Got it 👍 Im gonna attempt to use google cloud but if that does not work then ill have to go back to replit.
Thanks alot!
:/ Looks like im using replit, Google cloud, AWS and azure all are just free trials
I had my VM for 6 months and no issues beyond the fact its annoying to open ports
Scenario:
- I have an embed variable
- This embed variable has 25 fields using .add_field()
-```py
""" kinda some pseudo code"""
x = discord.Embed(title='example')
for i in range(0,25):
x.add_field(name=i,value=i)
b = x
- B should be first half of first embed
- X should be the 2nd half of first embed
How would i split this embed into two separate embeds?
how can i make a vertical list in an embed?
b!rtfm pyc Embed
https://docs.pycord.dev/en/master/api.html#discord.Embed.add_field
@errant verge inline=True
just the value part i mean
tbh i think inline is what u want but if not then no clue
.remove_field(idx)
would i just basically loop through the first 12 of x.fields to remove it?
i was hoping someone would say something like x.fields[:n] which was what i tried but i'll go with loops
Idk
i was looking for an "efficient" way but looping works
For link buttons I presume you can’t use class right?
So how would you use it without class
Since there’s no callback for link button I think? From what I read in the docs
Add it to the view with add_item
Ok!
Hey how can I create an authorize link and once authorized do you get a specific role?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
wym?
yeah but how i can when a user to click authorize the user a specific role ?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
my understanding is you make a request
Anyone know how i can add block discord invites?
Looks like u r adding someone elses bot
For a automod
U can look at his git repo to see how to do that
So people cant invite using that invite link?
no
like dyno if u send a discord link it delets it
Auto Modderation
?
why react?
So u r sending links to someone elses server?
Ahh i see
not really lmao
Try adding discord.gg to same list!
ok
And then u can do
If in[]
But y not use use startwith?
All links have discord.gg common so block that and u block all invites
Unless someone just posts the end
ill let u know if u have issues
can someone tell me why now >endDate return false ?
Yeah sure
Can u show what it outputs like everything
Been a minute since i used datetime moduel
what do you wnat to see ? I put a print for all variable
datetime is SOOO useful
See what time it prints
Ahh i see
nowTimezone: America/New_York
endTimeZone: America/New_York
now: 2022-06-14 22:11:39.011281-04:00
end: 2022-06-14 22:00:00-04:56
now >= self.endDate: False
I am half blind lol😂
I mean it should return true
Damn no idea with this 1 man not on pc rn
the only thing I see is the -04:00 and -04:56
at the end
but I have no idea what those are
Not sure what endtime is or u r getting it but y not just convert it to epoch time
Would be easy
Or try defining date and time formate!
Maybe there is some issue
I see thank you !
try converting them to unix timestamp int
so it’s only seconds from epoch
I did that and it seem to be working
now.strftime("%Y-%m-%d %H:%M:%S") >= self.endDate.strftime("%Y-%m-%d %H:%M:%S")
just block anything that has discord.gg/ and discord.com/invite
People can easily just use a link shortener tho
Just wondering but do you know an efficient or a good way of splitting an embed that has too many fields?
for example if i have 31 fields (ik 25 is the limit)
if you really need one embed, then considering using the footer and author fields
but then, you can always just have 2 embeds
i dont mind the idea of splitting
either group them by topic, or make them split even
x = discord.Embed()
x.fields # returns a list of fields
x.fields = #how i split array?
so something like this? gotcha
how can i print a field?
<discord.embeds.EmbedField object at 0x000001F0947273D0> to readable or must i just use to_dict?
.send(embed=embed)
oh, then to_dict
gotcha :/
thanks for the help
is it possible to stop global variables being used across different users in a command
?
are you looking for the data the uses to be stored temporarily or just saved?
temporarily
and is this data seperate to each user?
or is it just a variable used in that "session" once then changed
once
i cant pass arguments in callbacks so thats why i used global
then it brought problems as well
because im making pages
with buttons
and i cant pass shit in callbacks
so like
bruh = "asdhiasgdasd"
async def ChangeCategory(interaction):
#without using global
await Message.edit(bruh)
```how tf am i suppose to do this
create new attrib for that member instance
i believe we can
Member.data1 = shits
HOLY SHIT
WHY DIDNT I THINK OF THAT
So I'm using the stdlib logging module, but I only want the D, I, W, E, C rather than DEBUG, INFO, ...etc. Is there a way to do this? as %(levelname[0])s does not do that, and raises an exception
Edit:
So I ended up using logging.Filter and using this
class LevelFilter(logging.Filter):
"""
This is a filter which changes the levelname to that of its Initial letter
"""
def filter(self, record):
record.levelname = record.levelname[0]
return True
# ...
f = LevelFilter()
logger.addFilter(f)
where can more parameters like these ctx.invoked_subcommand , member.joined_at
or whatever they r called 
But it only works with slash command
i searched can't find them
ctx.respond works only on slash cmds
ctx.send works on both but will raise applicatiom didnt respond error with slash cmd
ctx.reply works with prefix
Search properly, everything is documented very well
Theres a search bar up top
i see thanks alot
If i was at my computer, I'd send you a screenshot of where you can find those
I'll send it if i remember
😐

seems like import error
it was just working
what is partialmessage?
post code
import os
from discord.ext import commands
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(
activity=discord.Game(command_prefix='~', name='Watching for / commands'),
intents=intents
)
@client.event
async def on_ready():
print(f"{client.user}Bot is loaded")
for file in os.listdir("./cogs"):
if file.endswith(".py"):
print("Loaded successfully")
print(file[:-3])
client.load_extension("cogs." + file[:-3])
py import isnt actually there

Ohh thnx
ya np
yes
It's correct?
exactly
Thanksssssss
np 
And how to run it ?
python kms
python edit()?
What is it
I'm pro
python edit()

better then me

Obsly

I made a lib for py
🤨
helo admin?
😱 omg
What is visco ?
ok
We are friends?
YESS!!!
DIES
So now what you think?
how do I restrict slash commands to roles in the v2 perms update? previously i used discord.commands.permissions.has_any_role() but that seems to have been removed, and discord.default_permissions() just is what a user has not roles, am I missing something or did v2 perms remove restricting slash commands via roles?
in the discord docs it shows you can, unless im reading it wrong
is it possible to send multiple modals
Here's the slash perms example.
https://github.com/Pycord-Development/pycord/tree/master/examples/app_commands/slash_perms.py
https://docs.pycord.dev/en/master/ext/commands/api.html#checks
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_perms.py at master · Pycord-Development/pycord
not sure why your sending that... all that shows is how to restrict it to specific perms, not roles
yeah, you can restrict roles, look through this and you should be able to find what you're looking for: https://docs.pycord.dev/en/master/ext/commands/api.html#checks
was looking for it but
thought it included a has_role example or check ¯_(ツ)_/¯
might be a good idea to showcase some utilization of checks outside of discord.default_permissions tbh
mhm
those checks are after the slash is sent right? i dont want them to show up at all
yeah, those checks will only raise an error that you can handle.
currently there is no way to gray out commands or hide them but that should come with backend/slate v2
yeah that was one of the things i searched for
ok so no it isnt possible, thanks
why was v1 perms discarded when all of the features from it were not added in v2?
as far as i can remember there was never a way to hide/gray out commands in v1
and I'm not entirely sure as to why, likely just because the first implementation may've been messy
guess im gonna downgrade then, it definitely let me gray them out in v1
How to make custom slash commands?
That user can make commands for their server
how can I add a delete button like this?
anyways how the fuck do i send requests to rule34.xxx api without it being blocked im using replit
import json, requests, random
Search = "himiko toga" # input
Image = random.choice(json.loads(requests.get(f"https://api.rule34.xxx//index.php?page=dapi&s=post&q=index&json=1&limit=500&tags={Search.replace(' ', '_')}", headers = {"Content-Type": "application/json"}).text))["file_url"] # find image
print(Image) #return
# works perfectly fine on my internet
# does not work in replit
# do i need a port or nah?
tbh you can probably just use a different host like oracle or railway
replit really isnt a good host to use
railway keeps telling me to verify
async def on_message(message):
if message.content.startswith("!hello"):
await message.reply("Hello!", mention_author=True)```
if i change the function name it doesn't work!

!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
can anyone help me with why me choices arent showing up in py async def status(ctx, player: discord.Option(str, choices=gmembers)):
I just get this
what is in gmembers variable?
An array of strings
you should put discord.OptionChoice(name=..., value=...)'s there instead of strings
Ohh, is there an easy way to do it for every item in an array?
no a standard array should work fine there
In the choices variable?
@bot.slash_command(guild_ids=server_ids, name='status', description='Gets the status of a player in the guild')
async def status(ctx, player: discord.Option(str, choices=gmembers)):
await ctx.defer()
getuuid = g(f'https://api.mojang.com/users/profiles/minecraft/{player}').json()
statusinfo = g(f'https://api.hypixel.net/status?key={hypixel_key}&uuid={getuuid["id"]}').json()
playername = ''
for letter in range(len(player)):
if player[letter] in formatchars:
playername += '\\'
playername += player[letter]
if statusinfo['success'] == False:
await ctx.respond(f'There was an error getting the status of {playername}')
else:
if statusinfo['session']['online'] == False:
statusEmbed = discord.Embed(title=f'{playername} status', description="Offline", color=0x00ff00)
statusEmbed.set_author(name=player, icon_url=f'https://mc-heads.net/avatar/{player}')
await ctx.respond(embed=statusEmbed)
elif statusinfo['session']['online'] == True:
if statusinfo['session']['gametype'] == 'SKYBLOCK':
statusEmbed = discord.Embed(title=f'{playername} status', description=f"Online\n playing Skyblock\n{sbareas[statusinfo['session']['mode']]}", color=0x00ff00)
statusEmbed.set_author(name=player, icon_url=f'https://mc-heads.net/avatar/{player}')
await ctx.respond(embed=statusEmbed)
else:
statusEmbed = discord.Embed(title=f'{playername} status', description=f"Online\n playing {statusinfo['session']['gametype']}", color=0x00ff00)
statusEmbed.set_author(name=player, icon_url=f'https://mc-heads.net/avatar/{player}')
await ctx.respond(embed=statusEmbed)```
Thats the entire command
hmmmm
can you change the Option a bit? Add a random string as a description between str and choices=...
like (str, "Choose Player", choices=...), no description=
Okay added it in, ill see if it works now
nope still not getting any of the items showing
why am I getting:
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
Your pycord isnt on the right version
oh ok, using a beta version
is that an issue?
do pip list and show the output
py-cord: 2.0.0b1
Ah you need to be on rc1
pip install git+https://github.com/Pycord-Development/pycord
oh ok, will do that. thanks man
No problem, happy to help
where to I set PrivilegedIntentsRequired tho? I checked the dev portal but can not find it...
!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
I do see that, thats also checked but I am still getting:
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
Oh that was the missing piece. Thanks again 
No problemo, im just chilling waiting for Nelo to respond :D
What does this mean like, is it the ID of the webhook or??
Ignoring exception in command coinflip:
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 126, in wrapped
ret = await coro(arg)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "Desktop/public-main/cogs/fun/coinflip-fun.py", line 13, in coinflip
await ctx.respond(random.choice(coinflip))
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/context.py", line 227, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 686, in send_message
await self._locked_response(
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 933, in locked_response
await coro
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/webhook/async.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 357, in invoke
await injected(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
Code?
import random
import discord
from discord import Embed
from discord.ext import commands
class Coinflip(commands.Cog):
def init(self, bot):
self.bot = bot
@discord.slash_command()
async def coinflip(self,ctx):
coinflip = ["Head", "Number"]
await ctx.respond(random.choice(coinflip))
def setup(bot):
bot.add_cog(Coinflip(bot))
HELP PLS
try using @commands.slash_command()
pls
could you please format your code and errors when you want help
try deferring the context at the start of the coinflip function
wouldnt it be @bot.slash_command()
it depends on what he named his variable as
btw guys, for webhooks do you use the web-hook or pycord supported one?
Pycord can make the webhooks, but i send it with aiohttp
idk if pycord can send it
do you use class?
or normal def
so you wouldn't use class for webhooks?
Hmmm idk, i just use it like at 9 async def
if it's being used in a cog, @commands.slash_command() has to be used
i updated pycord now my bot wont send messages
is there a way to revert back to the version i was using before?
Hmm, since I'm trying to use it with Class and uhh hidk what exactly I'm doing??
are ya doing ctx.respond?
what version you using?
also enable intents
ive always used this method in cogs 
so just make it send on the func then
Add the messages and message_content intents to your bot
my honest question is who doesnt
oh no
i haven't used cogs so... Need to learn em
f
@dull skiff
yh
nah its ez
started learning pycord like a week ago
cogs is meant like a class
help me
code?
same error
Class that contain a func that will shown on discord
^^
use env file for token
please keep the channel in english
how to make it?
he having it but he is like new on python so
if you want to speak in other langs use #international-chat
sry"
sorry sorry
remove the id part
its ok we all get carried away sometimes
?
Follow what it says over there
whats your pycord version?
and then
used pip install -U git+https://github.com/Pycord-Development/pycord in January.
used this to develop the bot
then pip install -U py-cord==2.0.0b7 yesterday
then the bot just broke
what u use ?
2.0.0RC
no ctx.respond
define the variable in the env file
Not neeeded 100%
is there any error associated?
nope just nothing
?
hmm
could you make a thread in #969574202413838426 , so your issue doesn't get lost in this channel @upbeat hill
is the link the rc1?
wait nvm
stack overflow have dark mode?
No
ok
you should ask more here, cuz im like to see ya gtranslated all things here xD
there a way to revert back?
yes
uninstall then reinstall?
If u read the error u will see "discord.errors.LoginFailure: Improper token has been passed.", So i assumed you dont read the logs
pip install -U git+https://github.com/Pycord-Development/pycord
type this in your terminal
you can use the git link or "pip install py-cord==2.0.0rc1
and it should switch over
btw does migrating from dpy work with that ?
my laptop still on dpy xD
you'll have to add a few more things
you have to uninstall anything from discord.py
okie i can do it
you'll have to install discord.ui
omg how u can see that
it will not work right
for modals views etc etc
i said you need to read the logs on ur server right
you wont.
you will get anything with
pip install py-cord==2.0.0rc1
pycord handles modals & views
^
for me I had to install them specifically
bruh. A simple question but effective to make a event
xd
unless I'm using different lib
i think it cant if ctx.send and ctx.respond work not the same
i need to write the token file location in the load_dotenv parameter?
yh
since keywords
well if ur file is "private" its ok to put it on ur code
you can also do it with a python or json file
but remember dont copy/screenshot that part
still got nothing
oh ok
have you enabled intents on the developer portal?
i just put it on mainfile so there is no pain XD
File "c:\Users\Teddy\Documents\dcbot\bot.py", line 10, in <module>
intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'```
now i got this
that is also fine xd
just use intents=discord.Intents.all()
believe so, it was working perfectly, then updated pycord then it just stopped
i think u doesnt enable on discord developer mybe
could you double check?
tutor
ye and set ur intent on discord dev to turned on
^
just tell me pls 🙂
idc just tell
GUYS I CANT ADD MY BOT
??
wdyn
refresh page?
i did
url generator
yep they are all on
wym
hm
???
@crystal verge
why is my Internet so slow now...
yea?'
choose url generator
i am on url gen
could make a thread in #969574202413838426 so its easier to help you
bot and applications.commands
check the bot
no eror code but my bot still offline
zoomed out
I am trying to add a delete button to my message that once a user clicks it the posted message from the bot will be removed. I tried:
b3 = Button(emoji="🗑", style=discord.ButtonStyle.gray)
async def b_delete_callback(interaction):
await interaction.delete_original_message()
But that seems to not do the trick...
https://discordapi.com/permissions.html
try to use this maybe?
A small calculator that generates Discord OAuth invite links
Send your code?
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
intents = discord.Intents.all()
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')```
is that all your code?
yes:v
well your issue is that you need bot.run(TOKEN) at the bottom of your file
ok thanks you
u mean client.run?
client.run(TOKEN)
yes sorry
both work
It was only cause his is client not bot
depends on his variable but yh
in terms of variable
mhm
I do super().run() 
mainly because I subclass commands.Bot but thats not the point 😅
i got this eror
clearly the variable TOKEN is empty
mhm here
yes
Did you put strings around the Token in the env file
yes
E.g.
DISCORD_TOKEN = "DJFSFHOFLDSFDAF"
{"my token"}
it should be in the env file
i write like this
so i need to write like this?
like this
NEKOT_DROCSID
javascript enjoyer while using python
i got a token.txt file
i write like this but still eror
just use client.run(#token)
proceeds to extract the Token 
ok
the problem is that he might show his token once again
LOL
ew js
ew web first
what happen now🥲
well it says add_item doesn't accept style
yeah its also straight from the docs. slightly adapted for testing it should be fine
ghost ping?
oh nvm
you removed client...
but i only remove the loadenv
can i use slash and prefix at the sam e time
import discord
from discord.ext import bridge
intents = discord.Intents()
intents.message_content = True
bot = bridge.Bot(command_prefix="!", intents=intents)
@bot.bridge_command()
async def hello(ctx):
await ctx.respond("Hello!")
They are a little bit buggy sometimes, just be warned. still useable tho
ok
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\LENOVO\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 1147, in on_connect
await self.sync_commands()
File "C:\Users\LENOVO\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 643, in sync_commands
registered_guild_commands[guild_id] = await self.register_commands(
File "C:\Users\LENOVO\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 473, in register_commands
prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
File "C:\Users\LENOVO\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
We have logged in as Tailgater#3934
import discord
bot = discord.Bot()
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
@bot.slash_command(guild_ids=[880742966606577704])
async def hello(ctx):
await ctx.respond("Hello!")
bot.run("token")
sooo ummm
whats the problem
you might have to reinvite your bot with the application commands scope turned on
ok
why i cant acces discord?
ok
elaborate?
like this
it says you are not using the library
not that you cant access it
how to use it
it's cuz you have a directory called "discord" and it conflicts with the package
or a file somewhere else called discord.py
might just be that, not sure
is the bot in more than 1 guild?
is something wrong with my folder?
look different
btw what theme
ohhhhhhhh you literally put the entire discord library into your project
its replit
Also
so basically go back to waht I first said
you aren't using discord.
i read it on stack overflow
cause it says it isnt being acessed
so what i need to do?
use it
ill give an example
import discord
from discord.ext import commands
client = commands.Bot(
command_prefix="!",
intents=discord.Intents.all()
)
@client.event
async def on_ready():
print(f"{client.user} is now online")```
thanks i can acces discord again
AttributeError: module 'discord.ext.commands.bot' has no attribute 'run' but i got this error
you always could ._.
you just werent even using the library
owh ok
"discord" is not accessed means you were not using the library
sorry because im so stupid
its ok
you do client.run()
i use bot.run
then have it be named as
bot = commands.Bot()
Also all your events will have to be
@bot.event not @client.event
it says has no atribute event
show full code of main file
from discord.ext import commands
from discord.ext.commands import bot
client = commands.Bot(
command_prefix="!",
intents=discord.Intents.all()
)
@bot.event
async def on_ready():
print(f"{client.user} is now online")
bot = commands.Bot("token")```
no no
import discord
from discord.ext import commands
bot = commands.Bot(
command_prefix="!",
intents=discord.Intents.all()
)
@bot.event
async def on_ready():
print(f"{client.user} is now online")
bot.run("token")
also dont import bot from discord.ext.commands
ah i finally know whats wrong
and my bot finally online
i didnt enabled the privileged intents
how do you send a embed from a interaction to a specific channel?
get channel object then await channel.send
am trying that but something is still wrong
self.channel?
you have the channel object already why not just await channel.send?
remove the
self.channel = channel
still getting same error
show me how you have it
remove the channel in
async def callback(self, channel, interaction)
do you use client or bot?
bot
you arent setting this to a channel variable
what do i do once it s set to a variable
channel = self.bot.get_channel(id)
await channel.send(embeds=[embed])
wait
you need
await interaction.response.send_message(embeds=[embed])
you cannot do it without it
so i cant send the modal results embed to a specific channel
I will try something
okie
i did this: https://guide.pycord.dev/interactions/ui-components/dropdowns/
But when i select an option it says it failed, and have no errors on console
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
im using the development version:
pip install -U git+https://github.com/Pycord-Development/pycord
could you make a thread in #969574202413838426 and show your code. thanks :)
he has i think
oop, will responde there lol
lol
How can I use a SlashCommandGroup across multiple cogs?
If I try making a group by the same name in multiple cogs, I get a "command names must be unique" error. If I try instantiating the group outside of the cog, then it seems to work, but the commands don't actually register
I get the same "command names must be unique" error if I try to use inheritance to get it
Hello !
How to make that a dropdown menu can be used by the user who use the command only ?
If you need my code dm me !
just help me pls
Ignoring exception in command coinflip:
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 126, in wrapped
ret = await coro(arg)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 852, in _invoke
await self.callback(self.cog, ctx, kwargs)
File "Desktop/public-main/cogs/fun/coinflip-fun.py", line 13, in coinflip
await ctx.respond(random.choice(coinflip))
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/context.py", line 227, in respond
return await self.interaction.response.send_message(*args, kwargs) # self.response
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 686, in send_message
await self._locked_response(
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/interactions.py", line 933, in _lockedresponse
await coro
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/webhook/async.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 357, in invoke
await injected(ctx)
File "Desktop/public-main/venv/lib/python3.10/site-packages/discord/commands/core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
code smh
import random
import discord
from discord import Embed
from discord.ext import commands
from discord import slash_command
class Coinflip(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.slash_command()
async def coinflip(self,ctx):
coinflip = ["Head", "Number"]
await ctx.respond(random.choice(coinflip))
def setup(bot):
bot.add_cog(Coinflip(bot))
Seeing your code you no need self.bot, just bot.get_chanel(id)
?
@sleek grove can you open your own thread in #969574202413838426
also when sending code use
```py
code...
```
this will format your code
i cant format code because im user and i have swiss layout
but i will copy it
i cant send a message
now it works
Hello !
How to make that a dropdown menu can be used by the user who use the command only ?
If you need my code dm me ! 
An easy way is to send it to the user with ctx.respond(..., empherial=True) this will make it so only the user who ran the command can see the message. (It is not a permanent message and will go away if the user restarts discord)
If you insist on making it globally-viewed, then you can do an author check in the callback.
Ho yes but the menu is IN the message and i want that the message Can be view by everyone
:
