Giter Club home page Giter Club logo

dnet-victoria-preconditions's Introduction

About the author

I'm Stévan Corre, a 18yo french developper.

Usage

Example command

[Command("pause")]
[RequireLavaPlayerState(LavaPlayerState.UserAndBotInSameChannel | LavaPlayerState.Playing)]
public async Task PauseCommand()
{  
    // this code will only runs if the bot is in the same channel as the user and if the lava player is playing some music

    LavaPlayer player = lavaNode.GetPlayer(Context.Guild);
    await player.PauseAsync();
}

Work with precondition returns

In order to get the return message from the precondition, you have to list for the CommandExecuted event.
Add this in your command handler. Read more here.

public async Task OnCommandExecutedAsync(Optional<CommandInfo> command, ICommandContext context, IResult result)
{
    // result contains the message
    switch(result)
    {
        case VictoriaPreconditionResult victoriaResult:
            // do something extra with it
            break;

        default:
            if (!string.IsNullOrEmpty(result.ErrorReason))
            {
                await context.Channel.SendMessageAsync(result.ErrorReason);
            }
            break;
    }
}

Available flags

Flags Description Default message Value
UserInVoiceChannel User must to be in a voice channel The user has to be in a voice channel in order to execute this command 1
BotInVoiceChannel Bot must to be in a voice channel The bot has to be in a voice channel in order to execute this command 2
BotNotInVoiceChannel Bot must not to be in a voice channel The bot is already in a voice channel 3
UserAndBotInSameChannel User and bot has to be in the same channel The bot has to be in the same voice channel as the user in order to execute this command 4
Playing The bot must be playing The bot must be playing in order to execute this command 5
NotPlaying The bot must be not playing The bot must be not playing in order to execute this command 6
QueueEmpty The player's queue must to be empty The queue must to be empty in order to execute this command 7
QueueNotEmpty The player's queue must be not empty The queue mustn't to be empty in order to execute this command 8

Setup

In order to import this package in your project, you can either download this repo as a zip and include files in your project, or install the nuget package with

Install-Package Victoria.Preconditions -Version 1.0.0

or here

dnet-victoria-preconditions's People

Contributors

aiixu 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.