-
Notifications
You must be signed in to change notification settings - Fork 0
Custom spawn messages
Important
This tutorial is now archived because Ballsdex has made their own way to add custom spawn messages. If you want to ditch this method of adding custom spawn messages in favor of the official method, simply update your bot using git pull and then make sure to rebuild using docker compose build.
You may have seen some dexes that have one custom spawn message or even multiple spawn messages. In this tutorial, we will be adding custom spawn messages in our bot. You will have the options of either sticking to one custom spawn message or having multiple random ones.
- Go to
ballsdex/packages/countryballs
You will see the following files:

- Open
countryball.pyin your text editor and scroll down until you see this part (or go to line 206):
extension = self.model.wild_card.split(".")[-1]
file_location = "./admin_panel/media/" + self.model.wild_card
file_name = f"nt_{generate_random_name()}.{extension}"
try:
permissions = channel.permissions_for(channel.guild.me)
if permissions.attach_files and permissions.send_messages:
self.message = await channel.send(
f"A wild {settings.collectible_name} appeared!",
view=self,
file=discord.File(file_location, filename=file_name),
)
return True
else:
log.error("Missing permission to spawn ball in channel %s.", channel)
except discord.Forbidden:
log.error(f"Missing permission to spawn ball in channel {channel}.")
except discord.HTTPException:
log.error("Failed to spawn ball", exc_info=True)
return False- Change
f"A wild {settings.collectible_name} appeared!",to anything of your choice.
Tip
Let's say if I wanna change my spawn message to say "A countryball to collect has appeared!", I will replace the line with
f"A {settings.collectible_name} to collect has appeared!",
Keep {settings.collectible_name} if you want the spawn message to address it's a countryball.
Once you replace the line, it should look like this:
extension = self.model.wild_card.split(".")[-1]
file_location = "./admin_panel/media/" + self.model.wild_card
file_name = f"nt_{generate_random_name()}.{extension}"
try:
permissions = channel.permissions_for(channel.guild.me)
if permissions.attach_files and permissions.send_messages:
self.message = await channel.send(
f"A {settings.collectible_name} to collect has appeared!",
view=self,
file=discord.File(file_location, filename=file_name),
)
return True
else:
log.error("Missing permission to spawn ball in channel %s.", channel)
except discord.Forbidden:
log.error(f"Missing permission to spawn ball in channel {channel}.")
except discord.HTTPException:
log.error("Failed to spawn ball", exc_info=True)
return False-
Save the file by pressing
CTRL + Son your keyboard orFile > Saveon your text editor, then close it. -
Restart the bot using
docker compose restart. Once it's back up, make sure the message works by using/admin countryballs spawnto spawn a ball.
Important
If you get "An error occured when running the command. Contact support if this persists.", you most likely didn't replace the line correctly. Check this by opening countryball.py and look for any errors you have possibly made trying to replace the line.
This section will be a bit more on the advanced side.
- In the
countryballsfolder, create a new Text Document.

- Name the file
spawnmsgsand change .txt to .py
A popup will ask if you are sure you want to change the file extension. Click "Yes" on this popup.

- Open the new file using your text editor. then copy and paste the following below into the file:
spawnmsglist = [
"Wow",
"Hello",
"The french",
]Important
If you want to add a new spawn message, look at the gif I made below to help you. Make sure you add a comma at the end of each spawn message you add, or you will get an error.

-
Save the file by pressing
CTRL + Son your keyboard orFile > Saveon your text editor, then close it. -
Open
countryball.pyand import the spawn message list by using this below:
from ballsdex.packages.countryballs.spawnmsgs import spawnmsglistIt should look like this:
from ballsdex.packages.countryballs.spawnmsgs import spawnmsglist
from ballsdex.settings import settings
if TYPE_CHECKING:
from ballsdex.core.bot import BallsDexBot
log = logging.getLogger("ballsdex.packages.countryballs")Then, scroll down to line 206 and replace f"A wild {settings.collectible_name} appeared!", with (random.choice(spawnmsglist)),
It should look like this:
extension = self.model.wild_card.split(".")[-1]
file_location = "./admin_panel/media/" + self.model.wild_card
file_name = f"nt_{generate_random_name()}.{extension}"
try:
permissions = channel.permissions_for(channel.guild.me)
if permissions.attach_files and permissions.send_messages:
self.message = await channel.send(
(random.choice(spawnmsglist)),
view=self,
file=discord.File(file_location, filename=file_name),
)
return True
else:
log.error("Missing permission to spawn ball in channel %s.", channel)
except discord.Forbidden:
log.error(f"Missing permission to spawn ball in channel {channel}.")
except discord.HTTPException:
log.error("Failed to spawn ball", exc_info=True)
return False-
Save the file by pressing
CTRL + Son your keyboard orFile > Saveon your text editor, then close it. -
Restart the bot using
docker compose restart. Once it's back up, make sure the spawn messages works by using/admin countryballs spawnto spawn a ball.
That is all for this tutorial. Once again, credits to porcelainscars for coding the multiple spawn messages.
If you have any errors, join the Ballsdex Developers server by clicking this blue text.