I was always focused on making game related things in my spare time so I wanted to create something new. Discord bots came in my mind after I have searched around for a while. There were some discord bots that were interesting like some could auto react to your messages or has a whole shop system attach to it. This was the moment when I wanted to create a Discord bot for my own Discord server.

What is Cosmic Bot

Cosmic Bot is a multi purpose (chat) bot created for a public community Discord server called ‘Cosmic Break Universal Alliance’. This includes functions such as spam/language filter, a schedule system, gachapon/lootbox system and a server shop.

DSharpplus, a C# Discord API wrapper library, a bunch of API integrations and other libraries have been used to create this bot.

Utility

The main reason why this bot is created is for its utility functions to make it easier to run the server. The utilities can be grouped into the following categories: ‘Moderation’, ‘Logger’, ‘Scheduler’ and ‘Tweet Translator’

Polls

Polls are useful to get quick results for a question without having to fill in a whole form etc. I have implemented this function in order to increase the member activities in the server. They are very flexible as well, I have implemented two versions of the poll command. One is the simplified version where you just give a question and some options. The other is the more advanced one where you can put images as a thumbnail or as a normal image.

Logger

This bot has message logging capabilities; whenever a member deletes/edits/said bad word, these will get logged by the bot and post them in their respective private log channels. These channels can be only accessed by moderators. In addition, it also logs moderator activities such as kick/ban/warn/mute.

Auto Moderation

The bot has auto moderation systems such as detecting whenever a member is spamming or sent a message containing a bad word in a channel. If a member is caught doing this, the bot will warn them about it. It may result in an auto mute if caught multiple times. I have implemented this system to reduce the amount of drama/fights happening in the server. There are also moderation commands available for moderators such as mute/kick/ban/warn.

To prevent raids, a recruitment channel has been made. When you join the server, you need a member role in order to participate in talks and have access to the rest of the channels. To get a member role, the user has to press a Discord Interaction Button from a message which gets generated by the bot. This ‘message generation’ module can be disabled by the owner or an admin to keep raiders out. In case the bot is offline, there’s a second channel where people can ask for a member role. This channel has slow mode activated to prevent spam.

Scheduler

I have implemented a schedule system where the owner or admin can add their own schedules to an embedded message and it works like a countdown. This is useful for game events so you don’t have to go to the game website to see when an event is going to start or end. An example would be to see how long you have until the current ‘battle pass’ will expire. The ‘Fluentscheduler’ library has been used to make the schedules work.

Tweet Translator

This game, Cosmic Break Universal, has official social media which posts useful information such as a summary of an update or when it’s done with maintenance. Since they are more active on the Japanese side of social media, they post more often there than the English one. Twitter is one of the platforms they are most active on. I have used IFFT, a service to connect social media apps with each other, to send certain tweets to Discord via webhooks. So when a new tweet comes from this certain user, it will get posted in the Discord channel. This message will get automatically translated by the bot and it will send a translated message in the same channel. Google Cloud API has been integrated to make these translations possible.

Fun

The other reason why I have made this bot is to increase the member retention percentage in the server. These systems will also help to distinguish this server from the others.

Server Rank

Every member has a server rank which get determined by a value called ‘EXP’. This value is saved in a member profile which is stored in a SQLITE based database. There are many ways to gain EXP; one of the main ways is to talk in the server. Server ranks are displayed as a role. This role also changes the color of the member’s name to distinct members from each other via its rank role.

Server Currency / Item Shop

This bot supports server currency where members can spend it on various items such as unlock bot commands and decoration roles. These items can be found in the server shop. Server currency can be earned by participating in various events like polls. Items owned by members are saved in their inventory which is stored in the database.

Decoration Role / Gachapon

Members can change their name color by using a decoration role. These roles can be obtained by purchasing it in the server shop. There are also unique decoration roles which can be only obtained from the Garapon (Gachapon). Garapons are capsule machines where you spend server currency to get a random item.