Skip to content
forked from d4n3436/Fergun

A multipurpose Discord bot written in C# using Discord.Net

License

Notifications You must be signed in to change notification settings

Tree1527/Fergun

 
 

Repository files navigation

Fergun

License: MIT Discord

Fergun is a multipurpose and multilanguage bot with lots of useful commands (Utility, Music, Moderation, and AI Dungeon).

You can invite Fergun to your Discord server clicking here.

Have any questions or need help with the bot? Join the support server.

Supported Languages

Language Human Translation
English
Spanish
Arabic
Turkish
Russian

Setup

0. Prerequisites

  • A Discord bot application (You can create one here).

  • .NET 6 SDK

  • A MongoDB server (You can get a Free Tier cluster here or install the system to your local machine here).

1. Building the bot

  • Clone the repository: git clone https://github.com/d4n3436/Fergun.git

    Or download from GitHub.

  • Build the bot (change Release to Debug in a debug build):

    cd Fergun
    dotnet build -c Release
    

2. Setting up a local Lavalink server (Optional)

If you want to use the music module with a local Lavalink server, follow these steps:

  • Install JDK 11+

  • Create a folder in the build folder called "Lavalink" (change Release to Debug in a debug build):

    cd src/bin/Release/net6.0
    mkdir Lavalink
    
  • Download the Lavalink binaries and save it in the folder:

    wget https://github.com/freyacodes/Lavalink/releases/latest/download/Lavalink.jar -O Lavalink.jar

    Nightly binaries:

    wget https://ci.fredboat.com/repository/download/Lavalink_Build/lastSuccessful/Lavalink.jar?guest=1 -O Lavalink.jar

  • Download application.yml and save it in the folder:

    wget https://raw.githubusercontent.com/freyacodes/Lavalink/master/LavalinkServer/application.yml.example -O application.yml

    Be sure to save it as application.yml and not application.yml.example.

3. Running the bot

  • Go to the build folder if you haven't done it before (change Release to Debug in a debug build):

    cd src/bin/Release/net6.0

  • Start the bot by double clicking Fergun.exe or with the command dotnet Fergun.dll.

  • You will see the error message: "No config file found. Creating default config file." The error is self explanatory.

  • In the build folder, open the file botconfig.json with a text editor.

  • Copy your bot token and paste it in the Token or DevToken field (Release or Debug build).

  • Fill the database login information in DatabaseConfig (If you're using a local database and no authentication then you don't have to change anything).

  • If you're using a remote Lavalink server you may also want to change the Hostname and Authorization fields in LavaConfig.

  • Start the bot again, now the bot should be running with the minimal config.

Note: If you set up a local Lavalink server the bot should be running the server automatically.

4. Testing and changing the default prefix

The default bot prefix is f! (f!! in Debug builds), a @mention can also be used as a prefix.

To test the bot use the ping command: f!ping. You should see an embed with the response times.

To change the default (global) bot prefix use globalprefix <newPrefix>: f!globalprefix !. This will set the global prefix to ! and save it in the database.

To change the prefix in the current server simply use prefix <newPrefix>.

To change the language in the current server use language.

To shut down the bot use logout.

5. More configuration

botconfig.json documentation:

Key Description How to get one / Notes
Token The bot token. Create a Discord application.
DevToken The development bot token, used in Debug builds. ^
TopGgApiToken The top.gg API token, used to update the bot server count in top.gg. Add a bot in top.gg, then here.
DiscordBotsApiToken The Discord Bots API token, used to update the bot server count in discord.bots.gg. Add a bot in discord.bots.gg, then here.
GeniusApiToken The Genius API token, used in the commands lyrics and spotify. https://docs.genius.com
AiDungeonToken The AI Dungeon user token, used in the AI Dungeon module. See below.
DeepAiApiKey The DeepAI API key, used in resize. https://deepai.org/api-docs
ApiFlashAccessKey The ApiFlash access key, used in screenshot and archive. https://apiflash.com
WolframAlphaAppId The WolframAlpha App ID, used in wolframalpha. https://products.wolframalpha.com/api
EmbedColor The raw value of the color the bot will use in its embeds. The default value is 16750877 or orange :)
SupportServer The support server invite. Get a server invite.
LogChannel The ID of the channel the bot will send error logs. Create a text channel and copy the ID.
PresenceIntent Whether the Guild Presences intent should be used. Used in multiple commands, required in spotify. If your bot is in more than 100 servers this requires verification and whitelisting.
ServerMembersIntent Whether the Guild Members intent should be used. Used in user join/leave/kick events and for downloading the entire member list. If your bot is in more than 100 servers this requires verification and whitelisting
MessageCacheSize The message cache size, used in commands that gets cached messages in a channel. The default value is 100, setting this to 0 disables the message cache.
MessagesToSearchLimit The number of messages to search in a channel. This is used in commands that searches for a Url in the messages of a channel.
AlwaysDownloadUsers Whether all users should be downloaded to the cache. ServerMembersIntent is required for this to work.
UseReliabilityService Whether the reliability service should be used. The reliability service is a service that shutdowns the bot in case of a deadlock.
The service requires that the bot is being run by a daemon that handles Exit Code 1 as a restart.
Daemon for Powershell and Bash.
UseCommandCacheService Whether the command cache service should be used. The command cache service is a service that tracks command (user) messages and the bot response messages.
When a command message is modified or deleted, the bot will also modify or delete the corresponding response message automatically.
UseMessageCacheService Whether the message cache service should be used. The command message service is a service that stores deleted and modified messages temporarily.
This service is used in the "snipe" commands.
MinimumCommandTime The minimum hours since a command has to be used in a server for the messages to be cached there. This is used in the optimized message cache.
Setting this to 0 disables this requirement.
DonationUrl The donation Url. ...
TotalShards The total number of shards to use. If this is set to null, the bot will get the recommended shard count from Discord.
LogLevel The minimum log level. The default value is 4 (Verbose).
DatabaseConfig The database configuration. ...
LavaConfig The Lavalink server configuration ...
(...)Emote The emotes that are used in some commands. LoadingEmote is used in a "Loading" message.
MongoDbEmote and WebSocketEmote are used in ping.
BoosterEmote and UserFlagsEmotes are used in userinfo.
The rest are used in serverinfo.

6. Obtaining the AI Dungeon token

(These steps may differ depending on what web browser you're using. Here I'll use Google Chrome.)

  • Go to https://play.aidungeon.io in your web browser and log in.
  • Open the Developer tools (press F12).
  • Go to the Network tab and click the WS button.
  • Press F5. A subscriptions connection should appear.
  • Click it, go to the Messages tab and scroll up to the first message.
  • Click the first message. The token is the value of the token key.

Contributing

Feel free to report bugs or request new features via issues or pull requests. Requesting new commands may or may not be accepted depending on the utility and usability of that command.

License

Fergun is licensed under the MIT license.

About

A multipurpose Discord bot written in C# using Discord.Net

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%