pycord-development / guide Goto Github PK
View Code? Open in Web Editor NEWThe official guide for Pycord
Home Page: https://guide.pycord.dev
License: MIT License
The official guide for Pycord
Home Page: https://guide.pycord.dev
License: MIT License
Most links on the event handler topic are 404 pages.
Go here https://guide.pycord.dev/getting-started/more-features
Under event handlers, click on few links. Most redirect to 404 pages. Examples:
The links should redirect to correct pages
Links are 404 pages
Chrome
No response
Needs example discord components
May need partial rewriting
ext.tasks
(#31)ext.pages
might be halted for now)ext.pages
ext.bridge
NOTE: might be ignored, for the initial release
Unless the team decides to create the page or a PR for it is made these aren’t required for release
This way, everyone gets the same version. I know some libraries are prone to breaking something even if it's just a minor version. Better to be safe than not.
Old Tutorial
I followed the instructions in Creating Your First Bot, and what led me here is the Coding the Basics section. The tab itself looks outdated, along with the images and instructions. I would love to contribute to fixing this, maybe.
Regarding the Coding the Basics section, I encountered an error, which is as follows:
Traceback (most recent call last):
File "PATH\Pycord\First Project\bot.py", line 6, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
I expected to have a working code and clear instructions because one example that confused me is Inviting the bot. It says, "Go to the OAuth2 tab in the left pane and select bot
and applications.commands
as scopes." However, in the Discord Dev Portal, there are two buttons inside OAuth2, namely General
and URL Generator
, but it doesn't mention these.
This isn't a major issue; what I want to convey is that the information in the tab appears outdated, and I haven't progressed to the other tabs beyond this point.
Regarding the code, as I mentioned earlier, I encountered an error, and I expected the code to work without any issues.
Encountered an error and got lost in the middle of the instructions.
Windows 10
Python 3.11.1
Google Chrome
VSCode for running the code.
No response
Describe the bug
The buttons lead to a 404 on github
To Reproduce
Click the "Edit this page" button at the bottom of any docs page, and observe the GitHub 404. Can be reproduced on (but not limited to) the following: Introduction, Installation, Creating Your First Bot, etc.
Expected behavior
It should not 404
Screenshots
Additional context
n/a
Checklist
Let's make sure you've properly done due diligence when reporting this issue!
Currently, for collaborators (people that can directly commit to this repo), you cannot directly commit to the main branch. I do understand why this is the case, but it's not the solution for all commits. The only type of commits that should have this restriction is commits that add WIP things and aren't immediate.
For example, if you're going to push a commit to main that fixes only one spelling error or multiple ones in the same file, then it should be committed directly to main. However, if you're going around fixing spelling errors in multiple files, then it should be indirectly committed to main (new branch, PR, merge).
Remember, this applies only to people that can commit directly to this repo. If you do not have such permissions, then ignore this issue.
It doesn't seem like the subclassing guide works -- by default, Python doesn't inherit decorators from parents (see eg https://stackoverflow.com/questions/3421337/accessing-a-decorator-in-a-parent-class-from-the-child-in-python for discussion of how to make it work), and py-cord doesn't seem to have done the custom work to make it work. The result is that, eg, the @slash_command
decorator is undefined in a subclass.
To Reproduce
Copy the first example from https://guide.pycord.dev/popular-topics/subclassing-bots:
$ cat > sample.py
import discord
class MyBot(discord.Bot): # subclass discord.Bot
async def on_ready(self): # override the on_ready event
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
@slash_command() # create a slash command
async def ping(self, ctx):
await ctx.respond('Pong!')
bot = MyBot()
bot.run('token')
$ python3 sample.py
Traceback (most recent call last):
File "sample.py", line 3, in <module>
class MyBot(discord.Bot): # subclass discord.Bot
File "sample.py", line 10, in MyBot
@slash_command() # create a slash command
NameError: name 'slash_command' is not defined
Expected behavior
Bot runs, with a ping
slash command defined.
The error is in Line 302
Basically, is missing some quotation marks that are needed when content is a string.
As all can see, there are some missing quotation marks at the end of "You guessed it!" response.
Hopefully it'll be fixed soon, will it?
Is your feature request related to a problem? Please describe.
Links, when placed in titles, have the same styling as when placed in normal text. It would be ideal for them to have the same font-family and color as other titles, but have the font-decoration set to "underline".
Describe the solution you'd like
As described in the previous section. I found that the following css worked:
#verification a {
font-family: var(--pyc-theme-title-family);
text-decoration: underline;
}
#verification a:not(:hover) {
color: unset;
}
Before:
After (using the CSS above):
Describe alternatives you've considered
n/a
Additional context
n/a
Is your feature request related to a problem? Please describe.
I think it'd be nice if you could see which "version" the hosted guide is, so at least the ones that care can look if something is already changed or not.
Describe the solution you'd like
discord.js guide does it
Describe alternatives you've considered
N/A
Other
I don't know how to add labels, else I'd do it :X
Add a user-app example
Add a user-app example
Add a user-app example
Reading example on main repo
Add a user-app example
When explaining how to protect tokens here, you use raw Markdown formatting (probably copied from a Discord message).
I think you should either make two separate code blocks or, alternatively, remove the first part and only keep the actual example with proper formatting, like shown below.
TOKEN = NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I
Also, the part about ignoring .env
files should probably be formatted like a Tip (the block with green background) because it is easy to miss but important to know.
When accessing pages from the search bar in the top-right corner, internal links give a 404 error.
When accessing the same pages from the left-side menu or from any other link, internal links work.
When explaining how to migrate from another library to Pycord here, you could add a paragraph with a short list of conflicting libraries that should be uninstalled before installing Pycord, mentioning that we can use pip freeze
to check if we have them installed. Currently, only discord.py
is being mentioned.
A syntax error in the User Commands code
Hi I am new to the community and I was reviewing the Pycord Guide, but I found a syntax error in the Context Menus section, specifically in the User Commands section, the error is that if you put the guild.ids=[] attribute in the decorator, the User Command does not work, but if you remove it magically works. On the assumption that I have it wrong, I would like you to add an explanation of how to do it right in the Pycord Guide.
Explanatory video
If this error does not occur, it should run normally.
Gives https error or simply does not give error, but it does not work.
No response
I am Hispanic and my English is very bad, so I used Deepl's translator to express myself, so I apologize if there is something wrong written.
Is your feature request related to a problem? Please describe.
The guide on Cogs seems to be not working. First of all, it was never mentioned that bot.load_extension()
needa to be awaited. Furthermore, function setup
also needs to be an async function with bot.add_cog()
requiring to be awaited
Describe the solution you'd like
Someone more experienced in Pycord needs to review if these problems are correct. If so, I can submit a PR with the changes necessary
Describe alternatives you've considered
Let everyone suffer 🤗
When explaining how to use the SlashCommandGroup in the second example here, there is no mention that we need to import discord
and then discord.SlashCommandGroup
, or that we have to do something equivalent like from discord import SlashCommandGroup
.
Is your feature request related to a problem? Please describe.
i made a bot in which i want that if user enter wrong answer in the modal (self.children[0].value)
all ui components should be disabled for him
Describe the solution you'd like
I want a feature that can help me ease this process
Describe alternatives you've considered
i tried using timeout asyncio sleep and many stuff but didnt quite get the desired result
Additional context
Is your feature request related to a problem? Please describe.
As of right now, sqlite3
is recommended on the "Rules and Common Practices" page. However, sqlite3
is synchronous and blocking, which, when considering many people reading this part of the guide are reading it with the idea that they can use this in their asynchronous bot, is... not great.
Describe the solution you'd like
Recommend aiosqlite
instead. Maybe put a warning against using the Standard Library sqlite3
.
Describe alternatives you've considered
asqlite
exists, but I can understand not wanting to recommend that.
Leaving the page as-is is bound to confuse developers.
See Pycord-Development/pycord#1775 for details
Have a Application Role Connection Metadata Guide Entry
Have an Application Role Connection Metadata Guide entry. This is a cool feature and info on how to use it should be more public and accessible.
Resources to get started:
https://discord.com/developers/docs/tutorials/configuring-app-metadata-for-linked-roles
https://docs.pycord.dev/en/master/api/clients.html#discord.Bot.update_role_connection_metadata_records
https://docs.pycord.dev/en/master/api/clients.html#discord.Bot.fetch_role_connection_metadata_records
Add an entry to the guide.
No response
No response
Describe the solution you'd like
A guide page made for application command cogs would be nice.
Additional context
There's only a cogs page for ext.commands at the moment (and an example cog in the ext.bridge guide).
The page called More Features currently has a small section about Events, a section about Embeds, and another section about Markdown. The name used for the page is too generic and doesn't give any information about the actual content found within.
I think it would be more appropriate to replace the More Features page with 3 separate pages: Events, Embeds, and Markdown. This way the users will be able to quickly find the information they are looking for because each of these sections will be listed in the left-side menu and thus be more visible.
Translation
I suggest translations for: German, French, Italian and Vietnamese.
Is your feature request related to a problem? Please describe.
The examples (particularly the discord chat) have somewhat childish and "edgy" jokes. While these jokes have their time and place, it would be better to uphold a more professional facade in our guide. New users judge will whether they'd like to use our package based off of what's in the guide, so while light and playful content is ok, we should pick topics that appeal to everyone.
Describe the solution you'd like
Examples should be changed to fit a more professional appearance.
Describe alternatives you've considered
n/a
Additional context
n/a
There are some discrepancies in the discord message components. Perhaps we should migrate to https://github.com/skyra/discord-components-react, a maintained adaption of the library we currently use.
Is your feature request related to a problem? Please describe.
Like the main repository, this repository needs labels for issues/PRs.
Describe the solution you'd like
Add the following labels:
Describe alternatives you've considered
N/A
Additional context
N/A
There is Docusaurus plugin that can help with translation process - https://docusaurus.io/docs/i18n/crowdin
Since i'd like to make Russian (and may be Ukrainian in feature) translation - that is something i personally would like to see.
As discord fixed the 1 hour delay in global command registration, it is no longer necessary to register guild commands instead of global commands when testing. Because of this, the guide has no reason to reference debug_guilds
as it's an unnecessary detail that will just confuse the user. Removing all references should provide the guide with more clarity.
Describe the bug
In the index page for the Interactions guide, there is an unintended code block.
To Reproduce
Expected behavior
The text is formatted correctly to not be a code block.
Additional Context
I haven't tested to see if this issue appears in the master branch, but it definitely does appear in the production branch.
Checklist
Wavelink does not work with py-cord because of discord.py
I did pip install wavelink then discord.py was installed automatically
The wavelink works with py-cord
The wavelink works with py-cord
https://guide.pycord.dev/voice/playing#starting-out
Can you remove wavelink from the py-cord guide because it does not work with py-cord?
Describe the bug
I wanted to remove users roles including everyone role
The full goal of above snippet is to make a verifier modal that activates when a button is pressed and if the reponse text is not = to solvertextmain which is a captcha string(random 6 letter string) , if it matches i want allow user to message and assign him verified role but if it doesnt match i wanna mute the user for 2hours and when 2 hours passes i want to drop a message that reenables the user to use slash command and stuff
I want to add a role to user but i am getting this error
To Reproduce
import asyncio
from time import time
import discord
import os
from discord.ext import commands
import logging
import dotenv
import random
import string
from captcha.image import ImageCaptcha
import discord.utils
length=6
dotenv.load_dotenv()
token = str(os.getenv("TOKEN"))
solvertextmain = ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(length))
file_name = "some_image"
#''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(20))
image = ImageCaptcha(width=280, height=90)
captcha = image.generate(solvertextmain)
image.write(solvertextmain, f"{file_name}.png")
listos=[]
config = None
verify_channel = None
mute_roleid =int(os.getenv("mute_roleid"))
verify_guild = int(os.getenv("verify_guild"))
verif_roleid= int(os.getenv("verif_roleid"))
everyoneroleid=int(os.getenv("everyoneroleid"))
kon=None
#globalvar
#loggerstart
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
#loggerend
client = discord.Bot()
@client.event
async def on_ready():
print( 'We have logged in as {0.user}'.format(client))
@client.event
async def on_message (message):
if message.author == client.user:
return
if message.content.startswith('/start'):
await message.channel.send('Hello!')
@client.slash_command(desciption="starts-bot") # Create a slash command
async def wallet(ctx):
emchad =discord.Embed(title="Solve Captcha to Continue", color=0x2ea4ff)
imgfile = discord.File("some_image.png", filename="image.png")
emchad.set_image(url="attachment://image.png")
await ctx.respond("Please complete captcha to continue",embeds=[emchad],file=imgfile,ephemeral=True, view=verifierView())
class MyModal(discord.ui.Modal):
global kon
global listos
def init(self, *args, **kwargs) -> None:
super().init(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Enter your wallet address below"))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Wallet Address")
embed.add_field(name="Your Wallet Address ", value=self.children[0].value)
member=discord.Member
guild=client.get_guild(verify_guild)
verifrole=guild.get_role(verif_roleid)
print(verifrole)
await interaction.response.send_message(embeds=[embed], ephemeral=True),
await member.add_roles(verifrole)
kon=self.children[0].value
listos.append(kon)
print(listos)
output=open("file.txt", 'a')
for row in listos:
output.write(str(row) + '\n')
class MyView(discord.ui.View):
@discord.ui.button(label="Click here to enter your address")
async def button_callback(self, button, interaction):
await interaction.response.send_modal(MyModal(title="Enter wallet address below"))
class verifierView(discord.ui.View):
@discord.ui.button(label="Click here to enter captcha code")
async def button_callback(self, button, interaction):
await interaction.response.send_modal(verifierModal(title="Enter captcha below"))
async def disable_all_items(self) -> None:
await super().disable_all_items()
async def enable_all_items(self) -> None:
await super().enable_all_items()
class verifierModal(discord.ui.Modal):
def init(self, *args, **kwargs) -> None:
super().init(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Enter Captcha code below"))
@commands.has_permissions(kick_members=True,manage_roles=True)
async def callback(self, interaction: discord.Interaction):
print(self.children[0].value)
global solvertextmain
print(solvertextmain)
if solvertextmain in self.children[0].value:
await interaction.response.send_message("Enter your Address",ephemeral=True, view=MyView())
else:
await interaction.response.edit_message(view=None)
await interaction.followup.send(content="TRY AGAIN AFTER 2 HOURS",)
member=discord.Member
guild=client.get_guild(verify_guild)
print(guild.me)
role = guild.get_role(mute_roleid)
verifrole=guild.get_role(verif_roleid)
print(role)
roles1 = member.roles #save the member roles
print(roles1)
await member.edit(roles=[]) #remove all member roles
#bring back the old roles)
#role=discord.utils.get(member.guild.roles, name="Muted")
await member.add_roles(role)
await interaction.followup.send("You have has been muted!")
await asyncio.sleep(3600)
print(role.name)
if member.roles == "Muted":
await member.remove_roles(role)
await member.add_roles(verifrole)
await interaction.followup.send("You have been unmuted!")
await interaction.followup.send(content="NOW TRY AGAIN",view=verifierView())
####################################################################
if name == "main":
client.run(token)
Expected behavior
I wanted to remove users roles including everyone role
The full goal of above snippet is to make a verifier modal that activates when a button is pressed and if the reponse text is not = to solvertextmain which is a captcha string(random 6 letter string) , if it matches i want allow user to message and assign him verified role but if it doesnt match i wanna mute the user for 2hours and when 2 hours passes i want to drop a message that reenables the user to use slash command and stuff
I want to achieve results as shown in this Rapptz/discord.py#5937 but when i send this command await member.edit(roles=[]) erorr occurs
Screenshots
Additional context
Checklist
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.