Пример #1
0
        public async void CreateConfirmationDialog(
            OpenedDialogs openedDialogs,
            SocketCommandContext context,
            Embed description,
            Action <Dialog> confirmAction,
            Action <Dialog> cancelAction)
        {
            var dialog = new Dialog();

            var message = await context.Channel.SendMessageAsync("Zgadza sie?", embed : description);

            dialog.DialogID      = message.Id;
            dialog.DialogOwner   = context.User.Id;
            dialog.Buttons["✔️"] = confirmAction;
            dialog.Buttons["❌"]  = cancelAction;

            var reactions = new List <IEmote>();

            foreach (var key in dialog.Buttons.Keys)
            {
                reactions.Add(new Emoji(key));
            }
            await message.AddReactionsAsync(reactions.ToArray());

            openedDialogs.Dialogs.Add(dialog);
        }
Пример #2
0
 public async Task Install(IServiceProvider map)
 {
     _client   = map.GetService <DiscordSocketClient>();
     _config   = map.GetService <Config>();
     _dialogs  = map.GetService <OpenedDialogs>();
     _services = map;
     // Hook the MessageReceived event into our command handler
     _client.ReactionAdded   += HandleReactionAdded;
     _client.ReactionRemoved += HandleReactionRemoved;
 }