Memer is a simple Discord bot that on user request randomly selects meme from Reddit or Imgur and send it on guild channel or private channel.
- Random Reddit image grabber
- Random Imgur image grabber
- NSFW meme filtering on demand
- Customizable subreddits and Imgur tags list
- Customizable prefix
Sends a random meme on channel. By default, it randomly chooses between sites (Reddit or Imgur), sources on sides (from a guild specific list of subreddits or imgur tags) and then memes. However, you can specify site and source from which you want your meme.
<prefix>meme
<prefix>meme <reddit|imgur>
<prefix>meme <source> <tag>
!meme
!meme reddit
!meme reddit memes
!meme imgur
!meme imgur meme
Lists all commands with their descriptions or description and usage of specific command. The list of available commands will vary depending on user's permissions.
<prefix>help
<prefix>help <command>
!help
!help meme
Commands that allow guild administrator to configure guild-specific bot settings. List of available settings:
- list of subreddits
- list of imgur tags
- prefix
- enable/disable filtering NSFW memes
<prefix>settings <list>
<prefix>settings <prefix> <value>
<prefix>settings <nsfw> <enable|disable>
<prefix>settings <reddit|imgur> <add|remove> <value>
!settings list
!settings prefix %
!settings nsfw enable
!settings reddit add starterpacks
!settings reddit remove starterpacks
!settings imgur add awesome
!settings imgur remove awesome
Simple, standard test command. Send !ping
and bot will replay with pong
if is accessible.
<prefix>ping
!ping
All these settings have to be placed in settings.json
file. Example settings are available in settings_example.json
file.
"token": "TOKEN"
Your discord authorization token.
"imgur_client_id": "CLIENT_ID"
Your Imgur Client ID
"prefix": "!"
Default bot prefix. Guild administrator can modify prefix for his guild.
"reddit_refresh": 15
Time in minutes for how often pool of memes from subreddit will be refreshed.
"imgur_refresh": 180,
Time in minutes for how often pool of memes from Imgur tag will be refreshed.
"guild_max_active_subreddits": 30
Defines how many active subreddits single guild can have on their list.
"guild_max_active_imgur_tags": 30
Defines how many active Imgur tags single guild can have on their list.
"imgur_refresh_force": false,
Due to rate limit which Imgur imposes on free accounts, application during startup will conduct check to determinate if there is a possibility that Imgur rate limit will be hit. So, basically if you set too many imgur_tags
combined with too low value for imgur_refresh
property, application will throw BotInvalidSettingsException
and starting bot will fail. If you wish to omit this check, change value of this property to true
.
Formula for calculating if rate limit may be hit:
(44640 / imgur_refresh) * count(imgur_tags)
Result should be rounded up.
"subreddits": []
List of default subreddits. When bot join new guild first 30 (or any other value specified by guild_max_active_subreddits
property) will be placed on guild active subreddit list. Guild can modify their list however they want.
"imgur_tags": []
List of all available Imgur tags. Contrary to guild list of subreddits, guild can modify their list of imgur tags by adding or removing only tags specified by this property. This is caused by Imgur rate limiting. First 30 (or any other value specified by guild_max_active_imgur_tags
) will be on guild active Imgur tags list.
- JDK v17.0.2 (or higher)
- Apache Maven 3.6.3 (or higher)
- MySQL Server
- Install MySQL Server: MySQL Installation.
- Create database: Database creation.
- Create database user: CREATE USER Statement, GRANT Statement. Bot has a database migration feature - every 5 minute the application checks if there are new files in the
sql
directory. If application finds new files, it will try to read them and execute SQL from these files. If you do not intent to use this feature create user with onlyCREATE
,REFERENCES
,INSERT
,SELECT
,UPDATE
andDELETE
permissions and after application creates all necessary tables, revokeCREATE
andREFERENCES
permissions. Otherwise, create user with the previously mentioned permissions and any other permissions you deem necessary.
Here you can read how to get Imgur Client ID.
- Go to Discord Developer Portal.
- Choose
New Application
and give it a name. - Go to
Bot
tab. - Click
Add Bot
and thenReset Token
. - Here is your token, save it, you will use it later to run a bot.
For the bot to work, you need to provide two configuration files:
settings.json
database.properties
You can use sample files,settings_example.json
anddatabase_example.properties
. Just rename them and provide some necessary information:
- from
database.properties
file:jdbcUrl=jdbc:mysql://localhost:3306/YOUR_DB_SCHEMA
- replaceYOUR_DB_SCHEMA
by name of yours previously created databaseusername=USERNAME
- replaceUSERNAME
by name of your database userpassword=PASSWORD
- replacePASSWORD
by password of your database user
- from
settings.json
file:"token": "TOKEN"
- replaceTOKEN
by your Discord token"imgur_client_id": "CLIENT_ID"
- replaceCLIENT_ID
by your Imgur Client ID
Modifying other properties is optional. You can read about settings.json
file here and about properties in database.properties
here.
- Open terminal in project root directory
- Execute commands:
$ mvn clean
$ mvn package
- Compiled source code should be in directory ./target/classes/ and .jar file in ./target/
Move sql directory and all configuration files into directory with bot .jar file. When you do this you are ready to run application. Open terminal in directory containing .jar file and execute command:
$ java -jar JAR-WITH-DEPENDENCIES-FILE-NAME.jar
When application is running, you can add bot to your guild:
- On Discord Developer Portal select your application and go to
OAuth2 URL Generator
tab. - Check
bot
option. - Select at least
Send Messages
,Manage Messages
,Embed Links
,Attach Files
permissions. - Copy
Generated URL
and go to that URL. - Select server and confirm.
- Now your bot should be running and be present in previously selected guild. To verify if everything is ok, send
<prefix>ping
command on guild channel.