コード例 #1
0
ファイル: test_dispike.py プロジェクト: ms7m/dispike
def test_valid_arguments_for_run_function(dispike_object: Dispike):
    with pytest.raises(ValueError):
        dispike_object.run()

    # test if ValueError is raised if unix_host and port are both set
    with pytest.raises(ValueError):
        dispike_object.run(unix_socket="unix://testingDispikeObject", port=21332)
コード例 #2
0
ファイル: bot.py プロジェクト: ms7m/dispike-example
from dispike import Dispike
from .commands.forex import forex

bot = Dispike(...)

bot.register_collection(forex.ForexCommands(),
                        register_command_with_discord=True)

if __name__ == "__main__":
    bot.run(port=5000)
コード例 #3
0
from dispike.response import DiscordResponse
from dispike.register.models import DiscordCommand

bot = Dispike(**json.load(open("configuration.json", "r")))

command_configuration = DiscordCommand(
    name="secret",
    description="Generate a super secret key for your tools!",
    options=[])


@bot.interaction.on("secret")
async def handle_secret(ctx: IncomingDiscordInteraction) -> DiscordResponse:
    return DiscordResponse(
        content=f"""
        
        Hello {ctx.member.user.username}..
        
        Only you can see this message. **Do not share this key with anyone!**.

        Your key: || {uuid.uuid4()} ||

        """,
        empherical=True,
    )


if __name__ == "__main__":
    bot.register(command_configuration)
    bot.run()