#General Help
1 messages · Page 32 of 1
I still think it’s not related to pycord
According to your error log
discord.errors.LoginFailure: Improper token has been passed.
i even reinstalled python and same error continues to happen
im literally clicking the copy button from the site
what does your token actually print
i am indeed clicking copy
"none"
that’s not the token
you go under bot and then there’s a token
bruh, its been a while, i am now stupid
that client secret is the oauth2 secret
gonna try it tho
It was definitely one of the problems
okay, half of my problems are solved
now the bot turns on
but 2 of my commands won't work
like ping
are they slash commands?
yes
you need intents and guild id
async def ping(ctx):
await ctx.respond(f'Rapaz, aqui tá dificil, tô a {round(bot.latency * 1000)}ms')```
you can add to the discord.Bot debug_guilds=[ID] so you dont have to copy and paste it in all commands
my other commands work in all places tho
a slash command without the ID would need 1h to be global
no, it’s basically how fast your discord client loads nowadays because discord’s backend v2 for application commands make them register instantly
only meme command won't work, all other commands are already global and working
what does that say
wait, really?
yes
the app did not respond
they changed it right?
yes
oh nice
like 2-3 months ago
error in console? and are you using an API to get memes?
i am using praw
to get reddit memes
from r/memesbrasil
you didn’t answer the first question
no error in console
yes, i was using an api
and i found out
that the subreddit it got memes from
got private
so he can't get memes from there
so it timed out
then it always timed out
and it took longer than 3 seconds for you to respond
now it still times out, but sends a meme right after
put await ctx.defer()
yeah, i was testing all of the commands to know which of them work and why not
and the very beginning of the callback
Taking this server as an example, if the bot has the role of Official Bot. It can only add roles to people below itself and a role below itself. It can add Guide Contributor to a Server Booster, but cannot add Staff the a Notable Contributor
pip list and send output
because you didn’t respond
yes
how many do you have
turn it into a text file and send it
i see
so the command would be like await member.remove_roles([role1])
or if u only have one would u do await member.remove_roles(role1)?
and this would be with the objects right not the ids?
uninstall discord-ui
yes
pycharm?
now uninstall py-cord and reinstall py-cord
restart your code editor
ok
why do you need discord.ext.commands anyways
this is why I use github to pin point which commit has an issue
even for stupid small projects
if you have a repository, you can keep rolling back until it works
The last role is 0
Sorry had to fact check myself
wait what ?!?
u said the bottom role is 0
Bottom one is 0.
kk
if u create a channel with spaces in the name, will it auto replace w underscores?
What exactly is this for? When I try to view what the emojis are it returns an empty list: https://docs.pycord.dev/en/master/ext/commands/api.html?highlight=commands bot emojis#discord.ext.commands.Bot.emojis
Oh wait never mind
I was printing the value before the client connected to Discord
how to use command permission: make slash available only to admins
i dont know about command perm v2
yes
where should i use discord.default_permission in SlashCommandGroup?
its not working
i can use that slash from alt
how do I set that up 
^^
installing pycord via terminal in pycharm doesn't work, I've tested in on 4 different machines
it says that it's installing pycord 2.0.0 but it doesn't have all the extensions
it's better to go to pycharm extension manager and add the git url
been struggling to get the discord.ui working for hours
Can't u just use command line?
why doesn't it work? await ctx.channel.purge(limit=count)
Do you use a slash_command?
yes
commands.command is not a slash_command command
how do you put views in cogs
how do you check if the message has an attachment and if so, get the url of that attachment? (inside the on_message event)
sorry, found how to do it!
Here's the slash cog groups example.
how to check for events in a cog using py-cord?
Use the @commands.Cog.listener decorator
aight! ty
Np
How do I supply the name of the emoji, such as dollar for 💵 to a discord.SelectOption. I've tried this:
discord.SelectOption(
label="Some Label",
emoji="dollar"
)
And I get the following error:
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.1.components.0.options.0.emoji.name: Invalid emoji
Ive tried other variations such as :dollar: and discord.PartialEmoji(name="dollar") but they don't work either and throw the same error. Any help is appreciated 🙂
Use the unicode version.
\💵
Ok thanks, but how do I convert the name of the emoji to the unicode version?
\:emote:
Will that work directly in vscode or do i have to manually do that and update the code?
@sudden path
Just run that here and you will get the emoji
how do i fix cogs not loading
:(
like if there is even a tiny mistake
the cog doenst load
and i have no idea what is wrong
how do you get the ids of all the members in the server?
Iterate through them and get the ID.
b!rtfm pyc Guild.members
Error handler doesnt work
Ignoring exception in command fish:
Traceback (most recent call last):
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 355, in invoke
await self.prepare(ctx)
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 286, in prepare
self._prepare_cooldowns(ctx)
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 271, in _prepare_cooldowns
raise CommandOnCooldown(bucket, retry_after, self._buckets.type) # type: ignore
discord.ext.commands.errors.CommandOnCooldown: You are on cooldown. Try again in 26.37s
@client.event
async def on_command_error(ctx, error):
title = ":x: An error occurred!"
if isinstance(error, commands.MissingRequiredArgument):
message = "Missing required arguments"
elif isinstance(error, commands.MissingPermissions):
message = "Missing permissions"
elif isinstance(error, commands.CommandOnCooldown):
title = get_response(type="cooldown")
message = "This command is on cooldown. Try again in {:.2f} seconds".format(error.retry_after)
elif isinstance(error, commands.CommandNotFound):
message = "Unknown command"
else:
message = "An unknown error occurred"
embed = discord.Embed(title=title, description=message, color=0xdd2e44)
await ctx.send(embed=embed)
I used this in a slash command tho
How do I get client.
I have some bot code in a different file (backend.py) and want to somehow get client/bot without importing it from bot.py
is there any way to?
ctx.client does not work
ctx.bot
b!rtfm pyc on_application
discord.on_application_command
discord.on_application_command_completion
discord.on_application_command_error
discord.Bot.on_application_command_error
discord.Bot.invoke_application_command
discord.Invite.target_application
discord.Permissions.use_application_commands
discord.ext.commands.Bot.on_application_command_error
discord.ext.commands.Bot.add_application_command
discord.ext.commands.Bot.get_application_command
I have my bot named as client. ctx.client does not work
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'client'
it doesnt matter how you name the bot
ctx.client doesn't work though
because command context doesnt have that
check the docs
so uh is there any other way to get client?
kk
i told you ctx.bot
kk
what do you mean
all application command goes to on_app...
should be yeah
if you wanna have an error handler for both i suggest you make a function and run it on those 2 events
instead of repeating code
alright
Just record it using a dict or smthn
Every time someone bans someone, just update the dict
Well then record it in the db
Tho it's probably easier to use a dict stored in memory since it's prob not important that It carries over every time the bot is restarted
does anyone know how to get what users reacted to a message and what reaction they used after x seconds?
if message.content.startswith('$start'):
payload = await message.channel.send("image to react to")
await payload.add_reaction("1️⃣")
await payload.add_reaction("2️⃣")
time.sleep(5)
await message.channel.send('times up!')
users = set()
for reaction in payload.reactions:
async for user in reaction.users():
users.add(user)
print(users)
my current code (for some reason payload.reactions always is empty no matter how many accounts react)
payload.member = member
payload.emoji = emoji they reacted with
Here are the docs for payload: https://docs.pycord.dev/en/master/api.html?#discord.RawReactionActionEvent
sorry, I probably should have specified but this is within an on_message event so the 'payload' (that is poor variable naming on my part) is a message object not a reaction object
then payload is not defined as a payload event.
you would have to re-fetch the message with fetch_message to get the updated reactions.
ohh i see
class welcomeSetupCommand(commands.Cog):
@slash_command(name="welcomesetup", description="Start welcome setup", guild_ids=[923972845124583455])
async def welcomesetup(self, ctx):
await ctx.interaction.response.send_modal(welcomeSetupCommand())
class welcomeSetupModal(Modal):
def __init__(self) -> None:
super().__init__(title="Welcome Setup")
self.add_item(
InputText(
label="Welcome Channel ID",
placeholder="Example: 996570704487124993",
max_length=18
)
)
---> configUtils.getConfig(f'{guild.id}/welcome_settings.json', 'welcome_channel_id') <---
How do I get the guild id in Modal?
The easiest solution is not to subclass the modal
async def callback comes with the interaction parameter in which you can access interaction.guild.
squid can probably explain it better than me
class welcomeSetupCommand(commands.Cog):
@slash_command(name="welcomesetup", description="Start welcome setup", guild_ids=[923972845124583455])
async def welcomesetup(self, ctx):
await ctx.interaction.response.send_modal(welcomeSetupCommand())
modal = Modal(title="Welcome Setup")
modal.add_item(
InputText(
label="Welcome Channel ID",
placeholder="Example: 996570704487124993",
max_length=18
)
)
configUtils.getConfig(f'{ctx.guild.id}/welcome_settings.json', 'welcome_channel_id')
is probably easier
than subclassing
and you can add a callback with modal.callback = coro
Thx :D
that works, thank you 👍
is there like a limit on the amoung of commands you can have?
@strange ferry
You can have 100 commands, and each command can have up to 25 sub-command groups. Each sub-command group can have up to 25 sub-commands.
100 x 25 x 25 = 62.5k
Of course, "slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups", so you're not likely to hit that 62.5k command limit
i find a issue on cog.py, i leave a comment -> https://github.com/Pycord-Development/pycord/pull/1423#issuecomment-1184555787
bruh
#discussion
allright
my code stopped working, ctrl+z won't work to fix it
File "c:\Users\vinic\Documents\Yiffiy Pycord\bot.py", line 2, in <module>
from discord.ext.commands import has_permissions, MissingPermissions
File "C:\Users\vinic\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\__init__.py", line
25, in <module>
from .client import Client
File "C:\Users\vinic\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 53, in <module>
from .webhook import Webhook
File "C:\Users\vinic\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\__init__.py", line 12, in <module>
from .async_ import *
File "C:\Users\vinic\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 52, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\vinic\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\channel.py)```
is there a bridge command group?
Did you uninstall discord.py?
not yet
hmmm 😦
Is anyone else having Cog listener issues?
no
is there a persistant view example in a cog?
No
Mood
😄
isnt it just self.client.add_view()?
is it? i don´t know
i am trying it for 5 hours but it won´t work
Here's the persistent example.
yeah i am trying this and it won´t work for me
show code please
are there also any errors?
class PersistentView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Green", style=discord.ButtonStyle.green, custom_id="persistent_view:green")
async def green(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("This is green.", ephemeral=True)
@discord.ui.button(label="Red", style=discord.ButtonStyle.red, custom_id="persistent_view:red")
async def red(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("This is red.", ephemeral=True)
@discord.ui.button(label="Grey", style=discord.ButtonStyle.grey, custom_id="persistent_view:grey")
async def grey(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("This is grey.", ephemeral=True)
class PersistentViewBot(commands.Cog):
def __init__(self):
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
# Register the persistent view for listening here.
# Note that this does not send the view to any message.
# In order to do this you need to first send a message with the View, which is shown below.
# If you have the message_id you can also pass it as a keyword argument,
# but for this example we don't have one.
self.add_view(PersistentView())
self.persistent_views_added = True
print(f"Logged in as {self.user} (ID: {self.user.id})")
print("------")
@commands.command()
@commands.is_owner()
async def prepare(ctx: commands.Context):
await ctx.send("What's your favourite colour?", view=PersistentView())
def setup(bot):
bot.add_cog(TicTacToeCog(bot))
bot.add_cog(StreamControlCog(bot))
bot.add_cog(PersistentView())
uhh
why are you adding a view as a cog?
because i want it in a cog ?
but its a view
as you see bot.add_cog contains "add_cog"
so first you should remove that
i thought i have to register every class with add_cog in a cog 😄
another problem i see is your on_ready method
def setup(bot):
bot.add_cog(TicTacToeCog(bot))
bot.add_cog(StreamControlCog(bot))
bot.add_cog(HelpCommandCog(bot))
bot.add_cog(PersistnatViewBot(bot))
bot.add_view(PersistentView())
nope only the ones that subclass commands.Cog
like that?
your on_ready method should be an event
so add the decorator @commands.Cog.listener() above it
def setup(bot):
bot.add_cog(TicTacToeCog(bot))
bot.add_cog(StreamControlCog(bot))
bot.add_cog(HelpCommandCog(bot))
bot.add_cog(PersistantViewBot(bot))```
i did it
unexcepted argument bot in PersisentViewBot
since it is a cog. you should also have self.bot defined in your __init__ method
so
def __init__(self, bot):
self.bot = bot
self.persistent_views_added = False
okay
AttributeError: 'PersistentViewBot' object has no attribute 'add_view'
then you can just add the view with self.bot.add_view()
in the init?
nope in the on_ready event
do you see where you have self.add_view?
replace that with self.bot.add_view
there is
self.add_view(PersistentView())
i replaced it with self.bot.add_view(PersistentView())
yes just add .bot. in between self and add_view
yes
ok no error
if i use the command i got this error
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 748, in _parse_arguments
next(iterator)
StopIteration
During handling of the above exception, another exception occurred:
raise discord.ClientException(f'Callback for {self.name} command is missing "ctx" parameter.')
discord.errors.ClientException: Callback for prepare command is missing "ctx" parameter.
oh ye
ok i go eat pizza ig
😄
thnx plun
okay it works fine 🙂
THANK YOU ALL !
🙂
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 877, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "/home/bots/discord/Aromic4All/python/commands/moderation/welcomeSetupCommand.py", line 26, in welcomesetup
await ctx.interaction.response.send_modal(welcomeSetupCommand())
File "/usr/local/lib/python3.9/dist-packages/discord/interactions.py", line 922, in send_modal
payload = modal.to_dict()
AttributeError: 'welcomeSetupCommand' object has no attribute 'to_dict'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 358, in invoke
await injected(ctx)
File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'welcomeSetupCommand' object has no attribute 'to_dict'```
async def gain_command(loot, item, author_id):
if await get_item(item_id=item, by="uuid", inventory="player_inventories", id=author_id) is not False:
chance = randint(1, 100)
for key, value in fish.items():
if value[0] < chance and chance < value[1]:
await add_item(item=key, id=author_id)
item = await get_item(item_id=key, by="uuid")
return f'You caught **{item["icon"]} {item["name"]}**!'
else: return False
@commands.slash_command(name="fish", description="Go fishing")
@commands.cooldown(1, 120, commands.cooldowns.BucketType.user)
async def fish(self, ctx):
await gain_command("7fea4d63-c02a-4057-832a-ba460b8dedc2")
"gain_command is not defined"
yeah? and then reinstalled py-cord
but as i said, it keeps coming back
Run pip freeze and screenshot
aiofiles==0.6.0
aiohttp==3.7.4.post0
aiosqlite==0.17.0
async-generator==1.10
async-timeout==3.0.1
asyncio==3.4.3
asyncio-extras==1.3.2
asyncpraw==7.5.0
asyncprawcore==2.3.0
attrs==21.4.0
beautifulsoup4==4.11.1
brotlipy==0.7.0
bs4==0.0.1
cchardet==2.1.7
certifi==2022.6.15
cffi==1.15.1
chardet==3.0.4
charset-normalizer==2.1.0
colorama==0.4.5
dblpy==0.4.0
idna==2.10
multidict==6.0.2
orjson==3.7.7
praw==7.6.0
prawcore==2.3.0
py-cord==2.0.0
pycares==4.2.1
pycparser==2.21
PyNaCl==1.5.0
python-dotenv==0.20.0
ratelimiter==1.2.0.post0
requests==2.23.0
saucenao-api==2.4.0
soupsieve==2.3.2.post1
typing_extensions==4.3.0
update-checker==0.18.0
urllib3==1.25.11
websocket-client==1.3.3
yarl==1.7.2
youtube-dl==2021.12.17```
wait a second, i will uninstall and reinstall pycord
bruh, its working
i had to reinstall py-cord
dblpy==0.4.0
this library has a depends on discord.py
yeah, this is a library for top.gg
upgrade to the github release for that library
OHHHHHHHHHHHHH
which removed that dependency
that doesnt mak any sense
hello everyone, is there an load_extension limitation on how much extensions i can load?
you need to call it from the cog
its OOP basics
what
ig you should learn oop
ah nvm
your ram
i dont even know what that is
bruh i have 16gb wdym

as long as your computer can handle the cog, you can do it
then why is my cog isn't loading properly and other do?
what does that mena
learn object-oriented programming before starting with py-cord
learn python**
then why are you asking
then you probably should know the issue in your code
bc i forgot that it was being executed from the main file
[...]
bot.load_extension("cogs.admin_main")
bot.load_extension("cogs.guild_whitelist_events")
bot.load_extension("cogs.logs")
bot.load_extension("cogs.escrows")
bot.load_extension("cogs.xp_system")
bot.load_extension("cogs.config")
bot.load_extension("cogs.user")
bot.load_extension("cogs.token")
bot.load_extension("cogs.marketplace")
bot.run(plugins.get_token())
cogs/marketplace.py
from turtle import position
import discord
from discord.ext import commands
from discord import OptionChoice, option
from discord.commands import SlashCommandGroup, Option
import plugins
import aiohttp
import asyncio
from typing import Union
import random
class Marketplace(discord.Cog):
def __init__(self, bot):
self.bot = bot
mp = SlashCommandGroup(
'mp',
'Marketplace commands'
guild_ids=[993502625574162552]
)
@commands.Cog.listener()
async def on_ready(self):
print("ye")
[...]
any ideas?
no errors
right
nah
no
and no output from on_ready in cog
but when i do the same on_ready in another cog it prints it
does changing the order affect it?
so it's specifically the marketplace cog
yes
there is a setup function at the bottom of the cog, correct?
is there a way to add aliases to slash commands?
i don't think so
nope
it isn't
dang it
so everything is syntactically correct
yes
py-cord version?
How can i do a dropdown menu with all Channels?
py-cord==2.0.0
Create a dropdown and use the append_option for every channel you want to add, although there is a 25 option limit
@slow domebro i am dumb af
wat
...
why it didnt throw me an syntax error
¯_(ツ)_/¯
discord.Color(0xFF0000)
Thx
how do i create a slash command using cogs?
Here's the slash cog example.
so i've got this:
await v.timeout_for(duration=datetime.timedelta(minutes=29*24*60), reason=".")
and yes the member object is working etc
but i keep getting this error
In communication_disabled_until: Invalid communication disabled timestamp```
a delta is like a +5
so if you want 0+5
not just +5
await v.timeout_for(duration=datetime.datetime.now()+datetime.timedelta(minutes=29*24*60), reason=".")```
like this await v.timeout_for(duration=datetime.datetime.now() + datetime.timedelta(minutes=29*24*60), reason=".")
ight
yes
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'datetime.datetime'
I want to assign a role to everyone on the server.
I used server.members to get all members but it returns only 2, the bot and me. How can I get past this?
Members intent.
Here's the edits example.
Next time you can do it on #app-commands ;)
With the on_member_remove Listener, is it possible to get why they left? like kicked, banned or etc
If not present, they just left
does the limit input get the most recent ones?
limit is like how many before now
Ok
like it should be more recent first
Ok
from the AuditLogEntry object. How would I get the id of the user who was banned/kicked
i have this problem and i found that there's already had a post (https://discord.com/channels/881207955029110855/994800812607938560)
but the creator closed it. can i still use that post? or i should create a new post or just ask here?
So I want to send a message a specific amount of times, how would I do this? This was my attempt but it failed:
@bot.slash_command(name="desko-grenade",description="pings desko for a specified amount of times")
async def grenade(ctx, amount):
await ctx.respond("started the grenade",ephemeral =True)
for i in range(amount):
await ctx.channel.send("@plush grail")
try to convert amount from str to int? amount is string
type hint amount as int
is it done like this then?
@bot.slash_command(name="desko-grenade",description="pings desko for a specified amount of times")
async def grenade(ctx, amount):
int(amount)
await ctx.respond("started the grenade",ephemeral =True)
for i in range(amount):
await ctx.channel.send("@plush grail")
Yes that’s another way you can do it
nope, you have to assign that to amount again
@bot.slash_command(name="desko-grenade",description="pings desko for a specified amount of times")
async def grenade(ctx, amount: int):
await ctx.respond("started the grenade",ephemeral =True)
for i in range(amount):
await ctx.channel.send("@plush grail")```
oh ok, thanks! Would this work the same for converting to other types?
does anyone know how to blacklist a user from using slash commands with an sqlite databse. I got the database down but I cna't use an on_message sinceslash commands don't work like that
I tried creating
acustom decorator
but it doesn't seem to work
the decorator doesn't even get executed
send your decorator code
I just meant if you would like to convert it to a float for example, but that would probably never be needed
then type hint it as float if needed.
def calltracker(func):
@functools.wraps(func)
def wrapper(*args):
if args.author.id in blacklist:
return func(*args) # this obviously doesn't work but even if I did it like this and it did work I would have an await problem
return wrapper
the wrapper is bad since args.author.id
won't work
but it doesn't even get executed
and I get an error with a coroutine
a typeError
command function must be a coroutine function
Tbh i'm not very good with doing custom decorators, since I don't use them nor want to use them. So sorry but I can't help you, i'm sure someone else can tho
do u know any other way of blacklisting someone?
from slash commands
in d.py
why are you using discord.py and asking help here
so thought I could ask even tho its the pycord official server
pretty sure the slash commands aren't the same.
so we can't help you, sorry.
o alr ty
hey can anyone help in #997120888761749636
When I print this, [] comes out, why?
When I do guild.name or guild the name of the guild comes up and with guild.id the id but why does guild.channels and guild.text_channels not work?
intents?
intents = discord.Intents.all()
client = commands.Bot(command_prefix="!", intents=intents)
Try doing self.client.get_guild(guild_id instead, without awaiting it.
is this effect?
fetch_guild or get_guild?
yea
get_guild
Ok
b!rtfm pyc bot.get_guild
why doesn't client have get guild
'NoneType' object has no attribute 'text_channels'
are you in the guild
Yes
i mean the bot
yes ik
does it have permissions to view channels
The bot has admin
discord.http.API_VERSION = 9
put that at the top of your code
before you define your bot
About the imports?
ok
not that high up
yes
then idk
Mhh :/
try explicitly setting the intents:
intents = discord.Intents.all()
intents.guild = True
Why is this?
because it sets it to true
b!rtfm pyc intents
AttributeError: 'NoneType' object has no attribute 'text_channels'
change it to fetch_guild
Result: []
well this is fun
Use get_guild. fetch_guild doesn’t return channels I’m pretty sure. Found something related to this on stackoverflow
Then comes this: AttributeError: 'NoneType' object has no attribute 'text_channels'
Why is it a nonetype 🤔
Are you sure the guild id is correct
yes
Is the id a string?
Just to be sure, can you show the whole command plz
Oh yea xd
thank u I am so tired😂
Np
No. Don’t do that 
when using cogs howcome i can not use the module easy_pil
if i put import easy_pil it will not loadthe cog
What version of py-cord are you using?
Did the cog load or no?
basically it loads the cog
Ok so then it probably didn’t load
Read from this message link below regarding cogs not loading on 2.0
#discussion message
is it an error because of that line?
well no
the cog just decides not to load
because of that line
_ _
im pretty confused
Yes we see that 👀
lmfao

rip
i cant move on if i dont fix this

basically the cog loads fine without
import easy_pil
but when i put import easy_pil it just stops working
so cog doesn't load because of import xd
try moving import around
wdym by that
import discord
# smth here
import easy_pil
fun
fun
this sounds like something really strange
it works when no import?
yes
yes
could you try using import thing as thing2
python being python 
just in case lol
okey
import easy_pil as your_mother no workey
still ignores the cog
sadge
😭
do you have any files named easy_pil
nah
do you have any variables named like that
i have a file called main.py a folder called cogs a folder called storage and a file called templates (for html)
nop
sadge
you've installed easy_pil
yea
nop
😔

ye
for event in os.listdir("./cogs/events"):
if event.endswith(".py"):
client.load_extension(f"cogs.events.{event[:-3]}")
print(f"load {event}")```

import discord
from discord.ext import commands
import json
from modules.views import WelView
import easy_pil
class OnJoin(commands.Cog):
def __init__(self, client: commands.AutoShardedBot):
self.client = client
print("funny")
@commands.Cog.listener()
async def on_member_join(self, member):
#funny funny code
def setup(client: commands.AutoShardedBot):
client.add_cog(OnJoin(client))```
it prints load on join
but not print funny
try using discord.Cog instead of commands.Cog

jic™️
i just realised what i did wrong 💀 im gonna sound like a dumbass when i say what i forgot

i forgot to install easy_pil
problem solved?
i thought i didi
🤯
it should
and since it didnt say anything i assume i did
5 hours of forgetting to install something
and how did you realize
because i checked what i had installed after
and realised
it wasnt there
🙀

average me being me
😱

yes
How about you turn of your computer
that’s most of help anyways
Yes
fax
tags save a lot of time
How do I decorate slash commands inside a cog?
you put the ornaments on the slash commands

and make sure the slash command is sparkly clean
pls
you asked how to decorate them.
its discord.slash_command
how to make the bot server deafen itself?
slash permission works in slash subcommands?
no, only permissions for the whole command group
any other way then?
ctx.message.author.guild_permissions.administrator this works?
this check decorator works in slash?
yeah, but it doesn't gray out,
btw slash subcommands are not getting registered 💀
even when a single guild id passed
I wanted to get a user object by using await bot.fetch_user but it takes a really long time and slows down other commands. Does anyone know an alternative?
bot.get_user
But it only gets cached users, unlike await bot.fetch_user
I've tried that but it always returns None
Then user is not in the cache or the id is incorrect
The id is correct because it works with bot.fetch_user so then how does a user get in the cache?
Hello, i am trying to get a list with with every guild name and ID that the bot is in. but for some reasons the guild name is always "None" (except one for some reason)
my code:
print(bot.guilds)
What i get:
[<Guild id=461592141521485824 name=None shard_id=None chunked=False member_count=None>,
<Guild id=837590922610737162 name='Rainbow Six [DE] | BOT Test' shard_id=None chunked=True member_count=19> ------------------
]```
any solutions to fix this issue?
Hey is there a way to create slash command groups in cogs? I've been trying for the past 2 and a half hours, and still couldn't find a solution.
same bro, my sub commands also not registering
tried everything
That sucks man
from last 2 days, it worked earlier
What are you guys trying todo with your slash commands
^^
Like a year ago there was someone who asked this exact question on the github, and they said it wasn't implemented yet, I guess it changed now but I don't know how to use it.
slash sub commands not appearing
Code?
@fervent pine using 2.0.0?
working in my main bot, cant use now on test bot
Imagine pycharm
lemme downgrade to rc1
Already have 2.0.0 installed
okw orked
@commands.slash_command(description="Something")
async def your_cmd_name(
self,
ctx,
user: discord.Option(discord.User, "User", required=True)):```
gg
i remember i upgarded to 2.0 yesterday
Then fuck 2.0.0
Also I forgot to put the self in the first place 💀
are you guys beginners with coding?
No, it's my job. lmao
i was struggling since i upgarded to 2.0
SAME
everyone can easly get a verified bot even without coding
brr, just see man, try it
and see
ok now upgrade to 2.0 again
Do you guys have any ideas btw
I got no idea man
;/
I saw this, and I was like wtf
Why only this specific one
Maybe try get_guild
with the ids
Idk this is even the guild i most want to
Maybe cuz the bot is struggling cuz of the member size?
i tryed that same thing
Then idk man might as well be the lib
but in one, i can see name
I was also trying older versions / discord.py
as i said yes
yes
maybe cuz of member size (my guess) the server has almost 42K members with 200 channels
Yes lol way smaller
But that's still weird
Why wouldn't it show the names
It did until now
No matter the size
idk with a cmd and ctx.guild it is working fine and real fast so bruh
Meh
Idk anymore
Maybe try sending a message to each server and getting the context from it then deleting it and getting the names from the context.guild.name?
But that's long and stupid
lmao ye xd
It would work though
But would just result in a mess for every bot restart lol
YES
And you getting banned or flagged for spamming
Okay the version you told us to install works
Is that a beta or something?
beta 7 of 2.0 ?
Seems weird that the beta works better then the production
Why b7 and not rc1?
Yes
Sounds like a good coder. If it works don’t touch
Plus it's modulable so it's okay
rc1 buggy for me
In case something needs a change you can always go tinker yourself with the libraries
Meh it works on b7 for me so I won't change purposelessly.
👍
Thanks for the help @smoky path
Np good luck
Thanks bud you too
Thanks :D
slash subcommands again disappeared when i upgraded back to 2.0.0
:kekw:
bug prolly
Chill dude. Got damn it
Group subcommands doesn’t have the guild ids param
How can i delete message after click on Button?
Depends on what you're trying to delete
I try to delete the embed
b!rtfm interaction.response.delete
I couldn't find a documentation with the name interaction.response.delete! 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 interaction.response.delete
No results found when searching for interaction.response.delete in pyc
await Interaction.message.delete()
but im not sure
Yes indeed
can't import discord after installing py-cord
i had an older pycord version but i wanted to upgrade to 2.0
tried to install from pypi
oop nvm
i was trying for sub commands permissions unknowingly that they are still not implemented in sub groups. before that i was struggling for 2 days for slash to appear actually... 😦
i had pushed a new feature to my bot and forgot to add perm restrictions in it, hopefully no one miused it, so yea it works downgrading from 2.0.0 to .0rc1 worked
how do i check if an error is a keyerror
basically i have this:
@bot.event
async def on_command_error(ctx, error):
global error_count
if error is KeyError:
await ctx.reply("A key error occurred. Make sure that your arguments are valid.")```
now no matter what i try it just does not send that string. how do i detect that it's a keyerror?
o wait nvm i can just put a try except block in my command
there's already an exception for that on pycord
b!rtfm pyc discod.Exception
b!rtfm pyc commands.errors
discord.ext.commands.errors.ArgumentParsingError
discord.ext.commands.errors.BadArgument
discord.ext.commands.errors.BadBoolArgument
discord.ext.commands.errors.BadColourArgument
discord.ext.commands.errors.BadFlagArgument
discord.ext.commands.errors.BadInviteArgument
discord.ext.commands.errors.BadLiteralArgument
discord.ext.commands.errors.BadUnionArgument
discord.ext.commands.errors.BotMissingAnyRole
discord.ext.commands.errors.BotMissingPermissions
weather = str(weatherData2['list'][3]['weather'][0]['description'])
What is wrong with my code? i want to get the marked one
can you send the raw json
the formatter is confusing
4 sure
What type is weatherData2
it´s only the json loads
weatherData2 = json.loads(Response2.text)
from the response
what library are you using to get the weather? requests? aiohttp?
requests
then it’s response.json
thats the print of the response
right
no. there is no reason for async
it´s only a daily task
why dont you just straight using the file with json.load
also this
with this i have to write the file every day, read it. So it´s only in RAM
where´s the advantage?
idk if it wasnt from file
webhook = Webhook.from_url(url,session)
TypeError: from_url() takes 2 positional arguments but 3 were given```
bruh
oh ok
I just want to ask what code editor is this
JSON Viewer - Convert JSON Strings to a Friendly Readable Format
ah i think i know where is the problem
it´s a dict not a json
hmm does event can be putted in a cogs?
Here's the slash options example.
what’s a kwarg
are there specific docs on it?
yeah, do you know where i can find em?
thank you
How can I make something like a main command for example /fun and then a subcommand addemoji?
No they are just example pictures lol
This is only one example
I don't want to do anything with an emoji
How can I make something like a main command for example
/funand then a subcommandaddemoji?
I just want to make a subcommand
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_groups.py at master · Pycord-Development/pycord
Thx :D
Would this work with (description="")
yes
Thx
Can I still make a /main command so that there is /welcome where something is returned and /welcome subcommand
So like in the picture
You can't invoke the base group command unfortunately
Mhh ok
How do I create a SlashCommandGroup in a Cog?
And then how do I add that to the bot? I'm to stupid xd
Here's the slash cog groups example.
Oh thx xd
But something like 2 subcommands in a row is not possible, is it?
So something like /welcome role remove
it is
How?
Why is there a description on slash command groups? I can’t even find the description when searching in the commands. Where is this description readable?
Ah i See, thank you!
That’s the description of the command /welcome activate and not of the slashcommandgroup /welcome
Oh xd
Idk
The command /welcome activate is activated and displayed but the others like /welcome addrole are not.
And the error in the console comes up
why dont u just put them on one class instead of having 2
It is in different files so that it remains clearer
You can't create two slash commands group with the same name.
So it has to be in a class?
no, it has to be different name
Then one is called /welcome1 and the other /welcome2 or what?
that'd waste
Or just put the commands in the same class
What's the point of keeping them separate
"clean"
yea xD
What a dumb reason
having one file for 1 command is a waste
A code can be clean with many commands in it
Ok xd Then I just do it in a class haha
And how do I do that now?
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
Thx
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 992, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 358, in invoke
await injected(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1171, in _invoke
await command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 355, in invoke
await self.prepare(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 278, in prepare
raise CheckFailure(f"The check functions for the command {self.name} failed")
discord.errors.CheckFailure: The check functions for the command sell failed
[...]
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(discord.errors.CheckFailure, error):
await ctx.respond('📛 **You have not enogh permissions to execute this command!**', ephemeral=True)
else:
raise error
[...]
``` where bug (monkey image meme)
u gotta use on_application_command_error
didn't help
@commands.Cog.listener()
async def on_application_command_error(self, ctx, error):
if isinstance(discord.errors.CheckFailure, type(error)):
await ctx.respond('📛 **You have not enogh permissions to execute this command!**', ephemeral=True)
else:
raise error
still doesn't catch the error
is the indentation alright?
i think the syntax for isinstance is wrong
?
it should be isinstance(error, discord.errors.CheckFailure)
see if that works
How can I react with a custom animated emoji?
bot = ...
bot.animename = ""
@bot.event
async def on_ready():
bot.loop.create_task(animecheck())
@tasks.loop(minutes=1)
async def animecheck():
async with aiohttp.ClientSession() as cs:
async with cs.get("/recent-release") as r:
res = await r.json()
name = res[0]['animeTitle']
anime = name.replace('(', '')
anime1 = anime.replace(')', '')
searchanime = anime1.replace(' ', '-')
print(searchanime)
if name == bot.animename:
print("no new anime")
return
else:
bot.animename = name
image = res[0]['animeImg']
episode = res[0]['episodeNum']
subordub = res[0]['subOrDub']
async with cs.get(f"details/{search}") as r1:
res1 = await r1.json()
synopsis = res1['synopsis']
genres = res1['genres']
embed=discord.Embed(title=f"watch {name} here", url="", description=synopsis)
embed.set_author(name="New Uploads")
embed.set_thumbnail(url=image)
embed.add_field(name="sub or dub", value=subordub, inline=False)
embed.add_field(name="genres", value=genres, inline=False)
embed.add_field(name="Episodes", value=episode, inline=True)
embed.set_footer(text="BBMoon")
channel = discord.utils.get(bot.get_all_channels(), id=config.Animeupdatechannel)
await channel.send(embed=embed)
it wont loop it either has to send a message or a print but it doesnt do that what am i doing wrong here ?
How do I test if a modal was closed without being sent?
How can I check if the bot has a given permission (manage_roles in this case)?
you havent start the loop
ctx.bot.user is a ClientUser, which doesn't have permissions stuff
I figure I could probably get the Member object by querying the guild for the bot's user ID, then get the permissions that way, but that seems cumbersome
Ah, perfect, thanks
i did with bot.loop.create_task(animecheck())
ill try
So idk if this is the right place for it, but I'll go anyway
I'm trying to host my bot on heroku, everything works, only problem is that the slash commands don't show.
Any help would be appreciated!
Here are the logs of heroku:
2022-07-15T20:29:39.000000+00:00 app[api]: Build started by user {my email}
2022-07-15T20:30:16.177536+00:00 app[api]: Release v6 created by user {my email}
2022-07-15T20:30:16.177536+00:00 app[api]: Deploy 48637215 by user {my email}
2022-07-15T20:30:20.000000+00:00 app[api]: Build succeeded
2022-07-15T20:31:35.598773+00:00 heroku[worker.1]: Starting process with command `python main.py`
2022-07-15T20:31:36.290181+00:00 heroku[worker.1]: State changed from starting to up
2022-07-15T20:31:39.783050+00:00 app[worker.1]: Ignoring exception in on_connect
2022-07-15T20:31:39.784076+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-15T20:31:39.784113+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
2022-07-15T20:31:39.784114+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-07-15T20:31:39.784114+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/bot.py", line 1041, in on_connect
2022-07-15T20:31:39.784114+00:00 app[worker.1]: await self.sync_commands()
2022-07-15T20:31:39.784116+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/bot.py", line 643, in sync_commands
2022-07-15T20:31:39.784116+00:00 app[worker.1]: registered_guild_commands[guild_id] = await self.register_commands(
2022-07-15T20:31:39.784117+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/bot.py", line 472, in register_commands
2022-07-15T20:31:39.784117+00:00 app[worker.1]: prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
2022-07-15T20:31:39.784117+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/discord/http.py", line 360, in request
2022-07-15T20:31:39.784118+00:00 app[worker.1]: raise HTTPException(response, data)
2022-07-15T20:31:39.784135+00:00 app[worker.1]: discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
2022-07-15T20:31:39.784135+00:00 app[worker.1]: In guild_id: Value "Ellipsis" is not snowflake.
2022-07-15T20:31:41.391143+00:00 app[worker.1]: - 983272986058559508 (name: Matt3o0's Test Server)
2022-07-15T20:31:41.391194+00:00 app[worker.1]: - 996900588547751996 (name: Shitters Simulations)
2022-07-15T20:31:41.391194+00:00 app[worker.1]: The bot is in 2 guilds and ready for usage!
You've provided some guild_ids as "Elipse"
When u boot up something breaks when ur system goes in on_connect
And on top
U most likely copy pasted
And because of that
guild_ids=[...]
Look like that when its expecting integers
yeah, I copy pasted from the pycord guide so I was sure nothing was wrong in my code
Yeah
I'll remove the guild thing
No you can just remove it
😅
Heroku huh
Hmmmmmm
However expect delays on ur commands being added to that specific server
2022-07-15T20:44:40.303422+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-15T20:44:40.303438+00:00 app[worker.1]: File "/app/main.py", line 28, in <module>
2022-07-15T20:44:40.303515+00:00 app[worker.1]: async def on_ready():
2022-07-15T20:44:40.303527+00:00 app[worker.1]: TypeError: event() missing 1 required positional argument: 'coro'
it gives this now
@bot.event
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("The bot is in " + str(guild_count) + " guilds and ready for usage!")
@bot.event()
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("The bot is in " + str(guild_count) + " guilds and ready for usage!")```
😅
I think
I have a custom setup so 😂
ok lol, it's deploying now...
class Nightmarefever(AutoShardedBot):
def __init__(self, command_prefix=set_prefix, intents=intents()):
super().__init__(command_prefix, intents=intents)
self.__setup__classes__()
self.bot = self
Where would i and how would i add case insensitivity to this
Ok
it gives this now
2022-07-15T20:52:10.281548+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-15T20:52:10.281569+00:00 app[worker.1]: File "/app/main.py", line 27, in <module>
2022-07-15T20:52:10.281652+00:00 app[worker.1]: @bot.event()
2022-07-15T20:52:10.281670+00:00 app[worker.1]: TypeError: event() missing 2 required positional arguments: 'self' and 'coro'
Ooof
🥲
@bot.event
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("The bot is in " + str(guild_count) + " guilds and ready for usage!")
bruh
Idk
I am too tired to think 🤣
Sis
I am not supposed to improve the code just
Help make it work
👀
I mean sure. But what they are doing is just like 17 times less efficient
🤣 🤷
it’s like grabbing a fork and instead of going straight to the kitchen, you go the other way around the world and then reach your kitchen
It iz whqt it iz
¯_(ツ)_/¯
that’s pretty hard
put it in the super().__init__
@warped token
@bot.event
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("The bot is in " + str(guild_count) + " guilds and ready for usage!")
Maybe
also make the class name NightmareFever
;)
Aaah see thats an old version of it that i haven't fixed but i still need to add the case insensitivity
Da hell
What da
uhm, does the invisible character need to be there?
No
ok lol
then sleep
how do i stop "the bot didn't respond" from appearing in the chat when i don't need it to say anything?
U fix ur context manager?
Or don't use slashcommands?
you can’t, you can, however, prevent the inevitable by deferring
how?
what
b!rtfm pyc applicationcontext.defer
No results found when searching for applicationcontext.defer in pyc
Boi this ain't no chat
ctx.defer() as a coroutine
oh, k
I recommend #general
it gives this 🥲
2022-07-15T21:05:09.858250+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-15T21:05:09.858273+00:00 app[worker.1]: File "/app/main.py", line 28, in <module>
2022-07-15T21:05:09.858397+00:00 app[worker.1]: async def on_ready():
2022-07-15T21:05:09.858422+00:00 app[worker.1]: TypeError: event() missing 1 required positional argument: 'coro'
again lol
I am way to tired to think to fox that
what are your dependencies
The code is as follow
@bot.event
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("The bot is in " + str(guild_count) + " guilds and ready for usage!")
Line 28 breaks
Which is the on ready
For some reason
Do you have a requirements.txt
yes
If so, could you send it
oh, it doesn't have discord.py
It does
you can only use that?
If it had discord.py that error would've made sense
no, it just uses the discord namespace
Oh hmmm
what is your python version
3.9.13, same as on my pc
Namespace? Interesting.... so python has namespaces 👀
ig so
I'm not a cs major
So modules are namespaces in the sense




