Creating Custom Commands
Setting Up Your First Command
To begin creating a custom command, you want to navigate to the Data\CustomCmds
directory.
Once there, you want to create .py
file, as an example I am using example.py
.
Defining A Command
To register within the selfbot, commands must be initially defined with @Cheddlatron.Command()
.
This allows the bot to recognise that the file it is running is a command.
To 'name' your command you must use async def command-name(ctx)
and this is the name you will invoke the command with.
Example:
@Cheddlatron.command()
async def example(ctx):
If you would like your command to appear in the help panels, you will need to add description
and help
to the definition of the command.
Example:
@Cheddlatron.command(description=f"This is a example command." help="customcmd")
async def example(ctx):
In this example, customcmd would be the help command used to see it in help commands and description would be what is sent when the help command for the custom command itself is used.
Making The Command Do Something
The command system relies on discord.py which you can find the docs for here.
By referring to the discord.py docs, we can see that to send a message we must use
await ctx.send("")
Example:
@Cheddlatron.command()
async def example(ctx):
await ctx.send("Example")
The example command above sends the text "Example" into the discord chat where the command was invoked.
Using Functions
With custom commands, you use functions like you normally would in python.
Listed below are a few pre-defined functions we have made that you can use.
config_get('prefix')
This function allows for the users prefix to be shown within the custom command help menu.
create_folder(folder_path)
This function creates a folder and intakes folder_path as a string of where you want the folder to be made and what you want it to be called.
download_file(url, path)
This function downloads a file from a url to a specific path, both url and path are strings.
config_get(data)
This function gets a value from config.json, data is a string and is the name of the value you want to get.
config_edit(data, new_value)
This function edits a value in config.json, data is a string and is the value you wish to edit and new_value is what you wish to edit data with.
notif(message)
This function sends a windows notification, message is what the notification contains and is a string.
panelmaker(heading, body, cmdname)
This function creates messages to be sent as an embed, all inputs are strings, heading is the top line and title of the embed, body is the main text and cmdname is the command name.
clear_console()
This function clears the console.
send_webhook(title, description, webhook)
This function sends discord webhooks to a specific webhook link. Title is the title of the webhook, description is the description of the webhook and webhook is the link of the webhook. All inputs are strings.
getxsuper()
This function is used to generate an x-super-properties value to be used in requests to discords api.
scrape(guild_id, count)
This function is used to scrape all members in a discord server, guild_id is the guilds id as a string or integer, count is the guilds member count as an integer.
yougotnitrobro()
This function is used to check if the token currently in use has nitro on their account and returns "no", "basic" or "nitro" accordingly.
Imports
Below is a list of libraries you can use which are already imported into cheddlatron.
discord
time
os
base64
io
random
string
urllib.parse
urllib.request
json
requests
aiohttp
asyncio
ctypes
pyfiglet
re
threading
webbrowser
aiofiles
httpx
websockets
warnings
glob
typing
platform
locale
shutil
YoutubeSearch
bs4
pystyle
colorama
gtts
subprocess
sys
logging
uuid
notify-py
datetime
websockets
Union - from typing
YouTube - from pytube
Image - from PIL