discord_cakebot¶
Contents¶
Command List¶
General¶
!del¶
Deletes your previous message. Searches up to the previous 500 messages in the channel.
Usage¶
!del
!google¶
Generates a Google search link for a keyword. For lazy people like me.
Usage¶
!google <keyword>
!redirect¶
Redirects a message to another channel.
Usage¶
!redirect <channel mention> <message>
Examples¶
- Redirects message to #alt:
!redirect #alt Hi guys, from the main channel!
Music¶
!musicprefix¶
Sets the prefix for queueing music for your server’s music bot.
Usage¶
!musicprefix
- displays the current music prefix set for the server!musicprefix <prefix>
- sets the music prefix to <prefix>. Requires manage_guild or musicprefix permission.
The prefix can consist of multiple words.
Examples¶
- Set music prefix to
~play
:!musicprefix ~play
- Set music prefix to
! lm play
:!musicprefix ! lm play
!play¶
Queues music using the musicprefix for the channel (check with !musicprefix
)
Usage¶
!play <keyword/title/alias>
Not case sensitive. If multiple matches are found, cakebot will display 13 possible matches and prompt the user to !playid
.
Variants¶
!play
- Queues a song by name or alias!playid
- Queues a song by id!playalbum
- Queues all the songs in an album
Examples¶
- Will have multiple matches:
!play snow
- Exact match, play song:
!play sound of silence
- Exact match for alias:
!play haifuriop
!playalbum¶
Queues an entire album - variant of !play
. The songs to be queued are displayed in the same format as !search - use !page <number> to examine.
If the songs to be queued are correct, use !yes
to confirm and queue.
Examples¶
- Play album named snow halation:
!playalbum snow halation
!search¶
Searches the song database for a song with a matching alias/song/artist/album name.
Usage¶
!search <keyword>
Displays up to 13 results at a time. Not case sensitive. If there are more than 13 results, use !page <number> to access the required page.
Examples¶
- Search for songs with the kekyword snow:
!search snow
Modtools¶
!logchannel¶
Gets or sets the channel for logging messages.
Usage¶
!logchannel
- displays the current channel for logging messages!logchannel set
- sets the current channel as the logging channel. Requires manage_guild or logchannel permission.
!purge¶
Purges a given amount of messages from the current channel. Can specify a user to purge only their messages.
Usage¶
!purge <number>
- purges <number> of messages in the current channel. Requires manage_guild permission.!purge <user mention> <number>
- purges <number> of messages by <user mention> within the last 500 messages. Max <number> is 100. Requires manage_guild permission.
Examples¶
- Purge last 5 messages:
!purge 5
- Purge Clyde’s last 10 messages:
!purge @Clyde#1234 10
Permissions¶
!permissions¶
Gets or sets the cakebot permissions for a given user. This does NOT set server permissions, but rather permissions for cakebot commands.
Permissions are required for:
* !musicprefix
(set)
* !permissions
(set)
* !logchannel
(set)
Usage¶
!permissions
- displays your current cakebot permissions!permissions <user mention>
- displays current cakebot permissions for the mentioned userpermissions <user mention> <command|commands>
- add permissionsf or the given user. Requires manage_guild permission.
Examples¶
- Give Clyde musicprefix permissions:
!permissions @Clyde#1234 musicprefix
- Give Clyde musicprefix and logchannel permissions;
!permissions @Clyde#1234 musicprefix logchannel
Miscellaneous¶
!timedcats¶
Sends random cat images in timed intervals :3
Usage¶
!timedcats <number> <interval>
The interval can be m (minutes) or h (hours). Default number and interval is 5 m.
Examples¶
- Send cat images every minute for 3 minutes:
!timedcats 3 m
- Send cat images every hour for 10 hours:
!timedcats 10 h
Developing Modules¶
Custom modules are all built off the ModuleInterface, which specifies two main things:
- Common state that must be provided by your module to function properly (e.g.
command_handlers
andhelp_entries
), and; - Methods that each module is provided access to (e.g.
say()
andauth_function()
).
command_handlers
provides a mapping between a command said to cakebot in Discord, and a function which handles the command.
For example, in the sample module below, the command !foo
is mapped to the asynchronous function foo()
.
Sample Custom Module¶
Here we define a simple custom module with a single command: !foo
, along with its corresponding help entry file.
In mymodule_help.py
:
from modules.HelpEntry import HelpEntry
_foo_desc = 'cakebot says foo! '
_foo_usage = '!foo'
help_entries = {
'foo': HelpEntry('!foo', _foo_desc, _foo_usage, 'miscellaneous')
}
In MyModule.py
:
from modules.ModuleInterface import ModuleInterface
class MyModule(ModuleInterface):
async def foo(self, message):
await self.say(message.channel, "Foo")
command_handlers = {
"!foo": foo
}
help_entries = mymodule_help.help_entries
Loading Custom Modules into cakebot¶
- Add the import for your module into
Bot.py
- Add the module into Bot._modules, with a name to identify it for loading. Note this identifier cannot be a duplicate of any existing identifiers.
- Load the module in
run.py
usingbot.load_module(identifier)
, with the identifier you chose above.
In Bot.py
:
from modules.core.Core import Core
# Other module imports...
from modules.mymodule.MyModule import MyModule
class Bot:
_modules = {
'core': Core,
# Other modules...
'mymodule': MyModule
}
In run.py
:
bot = Bot(client, logger)
bot.load_module('core')
# Other module loaders...
bot.load_module('mymodule')