示例#1
0
def test_raises_no_bot_token_registrator_object(dispike_object_no_bot_token: Dispike):
    from dispike.creating.registrator import RegisterCommands
    from dispike.errors.dispike import BotTokenNotProvided

    with pytest.raises(BotTokenNotProvided):
        dispike_object_no_bot_token.register(command=None)
示例#2
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()