Git Product home page Git Product logo

disukodo's Introduction

Disukodo - ディスコード

Modular discord.py API framework

Modular framework for rapid bot development. The process revolves around decorators for setting configuration.

Example

Sample Code -TestModule.py

from base import LOADER, ROLES
on = LOADER.CommandLoader()

class Module():

	def __init__(self):
		self.loader = on
		self.scope = None

	@on.cmdhelp("echo")
	def hlp_echo():
		return """
		**echo** [text]
		Prints back the text"""

	@on.command("echo")
	async def echo(event, client):
		await client.send_message(event.message.channel, " ".join(event.args[1:]))

	# Logs messages to console
	@on.message("log")
	async def printLog(event, client):
		print("(LOG)[{0}@{1}]{2}:\t{3}".format(event.server, 
			event.message.channel, 
			event.user.name,
			event.message.content))

Boilerplate

from base import LOADER, ROLES
on = LOADER.CommandLoader()

class Module():

	def __init__(self):
		self.loader = on
		self.scope = None

This is the skeleton for every module. It features the loader and the scope.

Command Help

	@on.cmdhelp("echo")
	def hlp_echo():
		return """
		**echo** [text]
		Prints back the text"""

This code gets returned in case of a command error, usually in cases where the syntax is invalid.

Command method

	@on.command("echo")
	async def echo(event, client):
		await client.send_message(event.message.channel, " ".join(event.args[1:]))

The code gets executed upon the detection of a <prefix>echo command with the command name defined in the decorator.

This code contains the actual command code, every event features two arguments, the event object and client object.

The event object is a Mapped dictionary containing event data. Depending on what event, the event object can contain event.user, event.server, event.timestamp, etc.

event.server is almost always present in all events

TODO

  1. A fair ammount of the events has been completed and are working. Role restrictions are still being developed.

  2. Persistent storage is also in the development roadmap so that the modules has a centralized configuration storage.

disukodo's People

Contributors

nokusukun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.