#waiting for interaction stops at the first person who use the commands when someone either use it

1 messages · Page 1 of 1 (latest)

rough jasper
#

i have a ?list commands that shows the list of item (embed) and below it a 2 buttons works fine the issue when some ethier use the commands the bot stop waiting for interaction from the first persone and working for the seconde person

#

im using the ctx.Client.ComponentInteractionCreated += async (s, e) =>

fast dock
#

Interactivity is a wrapper for event handlers, and thusly should not be used within an event handler.

rough jasper
#

and what i should do ?

stuck fiber
rough jasper
#

for sure

#

oh waffen

#

i still use

#

the ctx.Client.ComponentInteractionCreated += async (s, e) =>

#

that you told me you shouldn't use it

stuck fiber
rough jasper
#

XD

#

i think waitingforbuttonaysnc

#

make same problem

stuck fiber
#

Ok, in last time you didn't give you custom pagination class and i have tested version that was just showing numbers.

Let's try to fix your whole code together.

Can i look at your whole code?

rough jasper
#

here is it !

stuck fiber
#

"C:\Users\Discord\Files\list.txt" can i also get this file for test?

rough jasper
rough jasper
stuck fiber
# rough jasper the `ctx.Client.ComponentInteractionCreated += async (s, e) =>`

First:

static async Task MainAsync()
        {
            var discord = new DiscordClient(new DiscordConfiguration()
            {
                Token = "",
                TokenType = TokenType.Bot,
                Intents = DiscordIntents.All
            });

            var commands = discord.UseCommandsNext(new CommandsNextConfiguration()
            {
                StringPrefixes = new[] { "!" }
            });

            commands.RegisterCommands(Assembly.GetExecutingAssembly());

            discord.ComponentInteractionCreated += ClientOnInteractionCreated; // <--- here what i told about handling InteractionCreated

            commands.CommandErrored += (s, e) =>
            {
                Console.WriteLine(e.Exception.ToString(), e);
                return Task.CompletedTask;
            };

            await discord.ConnectAsync();
            await Task.Delay(-1);
        }

public static async Task ClientOnInteractionCreated(DiscordClient client, ComponentInteractionCreateEventArgs args)
        {
            switch (args.Id)
            {
                case "lastPage":
                {
                    // code here...
                    break;
                }

                case "NexPage":
                {
                    // code here...
                    break;
                }
            }
        }
rough jasper
#

that was i think

#

could pleas explain how switch works ? @stuck fiber

#

one more thing is this gonna make it for interaction for ever ?

stuck fiber
#

args.Id - it is you CustomId

You want to switch between values of this Custom Id switch (args.Id)

You can use case without {} like

case "1":
  // code
  break;

case "2"
  // code again
  break;
...

break must be in each case. But if don't use { } you can't use same variables

case "1":
  var line = 1;
  // code
  break;

case "2"
  // code again
  var line = 2 // error - because you have declared it before
  break;
...

{ } will fix it

More about switch case: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements

#

Also you can just use if else it could work too

rough jasper
#

thank you a lot @stuck fiber

stuck fiber
#

It is just example

stuck fiber
# stuck fiber

Is this what you expect to see in the work of your bot?

#

It is possible to change buttons, and make hyperlinks much better but like i've said it is fast video example

rough jasper
#

let me show u ...

stuck fiber
#

It is possible to make message like: "You can't use not your own list"

rough jasper
#

sorry for this bad recorde.

stuck fiber
stuck fiber
rough jasper
stuck fiber
#

yes

#

I've used 8 lines of code

#

For this video

rough jasper
#

could you share them :)

#

i spend my hole life wondring how to make this shit work (im new to this stuff )

#

can we just open live share in vs ?

stuck fiber
#

I can't spoon feed you here sorry. This code is same like in an example with emojies

#

Try it

rough jasper
#

lemm try it

stuck fiber
#

If you get problems with it i will help

rough jasper
#

can you join my server in my bio

#

just for test

stuck fiber
#

Okey, let's try :D

rough jasper
#

i set it to true

stuck fiber
#

Did it fix interaction failure?

rough jasper
#

yeah

#

and im stupid as fuck

#

Timeout= TimeSpan.FromSeconds(5),

#

this blocks the intreaction

stuck fiber
#

if you need infinity interaction just set it ti 99999, i don't know how to do it cleaner

rough jasper
stuck fiber
#

Try it

#

I am not using DsharpPlus.Interactivity in my projects

#

So i don't know many about this extension

rough jasper
#

anyway is there a way to customize the Pagination?

rough jasper
#

its wierd as you see

#

i got it

stuck fiber
#

Because pagination put selected text in first page

rough jasper
#

DSharpPlus.Interactivity.Enums.SplitType.Line

rough jasper
stuck fiber
#

Nice, if it works it is good

#

Did we solve your problem through week?)

rough jasper
#

yeah XD

#

thank you very matchhhh

#

ppl like u are rear

#

realy thank u

stuck fiber
#

Sometimes you need just look at the problem from a new angle

#

And the problem becomes very simple

rough jasper
#

for real

stuck fiber
rough jasper
#

i didnt think they have a ready function to do this

#

instead of my 60 stupid one

#

is the way that i make it good ?

#

im taling abt list

stuck fiber
#

it was interesting method, but too hard for this task ;)

rough jasper
#

tokes me a long time

#

anyway