Problems with SelectMenu discord.py - drop-down-menu

I'm trying to make SelectMenu to give out roles on the server I need to make it infinite, but I don't understand how. And besides, the one I wrote does not give out roles. I already third day sit with this error, and do not understand what is wrong. Bot does not even show what the error, the console is empty. here is the code. What do I have to do to make it work as intended?
#client.command()
async def sm(inter):
view =None
if inter.author.id == 1012357055987851345:
await inter.send('Text',
components = [
Select(
placeholder = 'Выберете роль',
options = [
SelectOption(label="Роль", value="Девушка"),
SelectOption(label="Роль2", value="Rainbow"),
])])
interaction = await client.wait_for("select_option")
selected = interaction.values[0]
if selected == "Роль":
user = inter.author
role = client.get_role(1029824401878810624)
await inter.user.add_roles(role)
await inter.send("Роли выданы")
if selected == "Роль2":
await user.add_roles(role)
await inter.send("Роли выданы")
And if you can, show me the working version as an example.
imports:
from msilib.schema import Component
from optparse import Option
import discord
from discord.ui import Select, View
import json
import os
import random
import asyncio
import aiohttp
from discord.ext import commands
from dislash import slash_commands
from discord_slash import SlashCommand
from discord_slash import SlashContext
import discord_components
from discord_components import DiscordComponents, Select, SelectOption, Button, ButtonStyle
from discord_components import *

maybe you can use discord.py2, it worked for me

Related

Laravel-FullCalendar-Scheduler using npm i fullcalendar-scheduler

https://github.com/JMackCo/Laravel-FullCalendar-Scheduler
public working repo commented with TODO
I have tried to use the npm i fullcalendar-scheduler.
I would like to be able to use the single package instead of
all the individual packages. I have searched and tried with
no success
I would like to replace this with the single fullcalendar-scheduler:
//JV TODO fullcalendar-scheduler
import { Calendar } from '#fullcalendar/core';
import interactionPlugin from '#fullcalendar/interaction';
import dayGridPlugin from '#fullcalendar/daygrid';
import timeGridPlugin from '#fullcalendar/timegrid';
import listPlugin from '#fullcalendar/list';
import adaptivePlugin from '#fullcalendar/adaptive';
import resourceTimeGridPlugin from '#fullcalendar/resource-timegrid';
import resourceTimelinePlugin from '#fullcalendar/resource-timeline';
import googleCalendarPlugin from '#fullcalendar/google-calendar';

Phaser 3. Importing phaser/src/core/Game produce error during runtime

The phaser game not starting error on
import Game1 from "phaser/src/core/Game";
import { Game } from "phaser";
console.log(Game1, Game);
const app = new Game1(gameSettings);
the following output of the console log which are similar class:
but when I trie to make use the one from the phaser js directly, no error found
import { Game } from "phaser";
const app = new Game(gameSettings);
Thanks in advance for answers which part I do wrong.
In all example I found on the web I see this kind of imports for Phaser
import 'phaser';
import Phaser from 'phaser';
import * as Phaser from 'phaser';
and then boot the game with
new Phaser.Game(config)

Unable to achieve expected transaction in karate-gatling for load testing [duplicate]

I am trying to reuse karate scripts and perform load testing using gatling. The scenario defined is to load constant 50 users per second for 10 seconds. (To load test 500 users) However the number of requests per second does not exceed 20 requests per second in the gatling report. Please let me know if i am doing anything wrong.
ExampleTest.java code which executes Karate scripts
//package examples;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
class ExamplesTest {
#Test
void testParallel() {
//System.setProperty("karate.env", "demo"); // ensure reset if other tests (e.g. mock) had set env in CI
Results results = Runner.path("classpath:examples").tags("~#ignore").parallel(10);
generateReport(results.getReportDir());
assertEquals(0, results.getFailCount(), results.getErrorMessages());
}
public static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList<String>(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}
Scala Code to define load test scenarios.
package perf
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.concurrent.duration._
class KarateSimulate extends Simulation {
val protocol = karateProtocol(
"/v2/" -> Nil,
"/v2/" -> pauseFor("get" -> 0, "post" -> 25)
)
val userfeeder = csv("data/Token.csv").circular
val getScores = scenario("Get Scores for Students").feed(userfeeder).exec(karateFeature("classpath:examples/scores/student.feature"))
setUp(
getScores.inject(constantUsersPerSec(50) during (10 seconds)).protocols(protocol)
)
}
We updated the docs (in the develop branch) with tips on how to increase the thread-pool size if needed: https://github.com/intuit/karate/tree/develop/karate-gatling#increasing-thread-pool-size
Add a file called gatling-akka.conf to the root of the classpath (typically src/test/resources). Here is an example:
akka {
actor {
default-dispatcher {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 100
}
throughput = 1
}
}
}
Since we made some fixes recently, please try to build from source if the above does not work for 0.9.6.RC4, it is easy, here are the instructions: https://github.com/intuit/karate/wiki/Developer-Guide
If that does not work, it is important that you follow this process so that we can replicate: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
Please see these links below for good examples of how others have worked with the Karate project team to replicate issues so that they can be fixed:
https://github.com/intuit/karate/issues/1668
https://github.com/intuit/karate/issues/845

Creating an Observable for Mock Data in Angular 2

I am trying to return an Observable from a service with mock data.
I am returning this from my service :
return Observable.of(new Object()).map(MOCKACCOUNT =>JSON.stringify(MOCKACCOUNT));
I get an error
Observable_1.Observable.of is not a function.
Am I missing some include? I am importing
import {Observable} from "rxjs/Observable";
Note: I was returning a mock promise prior but based on my understanding I would not be able to interpolate the value. For example {{returnFromServiceStoredInExportedClass.name}}
Looks like
import {Observable} from "rxjs/Observable";
should be
import {Observable} from "rxjs/Rx";
See also Angular2 RxJS getting 'Observable_1.Observable.fromEvent is not a function' error
Use
return Observable.of(new Object()).mapTo(MOCKDATA);`
The import statement is fine.
import {Observable} from "rxjs/Observable";
Also need to import the ts file for MOCKDATA
import {MOCKDATA} from "../path_to_mockdata";
Should be
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
because
import {Observable} from "rxjs/Rx";
will import all other operators that you don't need

Call a method of a web component and respond to events

I'm working on a Dart project where I have created a custom element with the Web_ui package that has some animation. What I was hoping to do is to have within the dart code for the element something like this....
class MyElement extends WebComponent {
...
void StartAnimation() { ... }
...
}
and then in the main() function of the dart app itself I have something like this...
void main() {
MyElement elm = new MyElement();
elm.StartAnimation(); // Kicks off the animation
}
The Dart editor tells me that Directly constructing a web component is not currently supported. It then says to use WebComponent.forElement -- but I'm not clear on how to use that to achieve my goal.
While you can't yet import web components into a Dart file, you can access them via query() and .xtag. xtag gives you a reference the web component instance that the element is associated with. You do have to be careful that you allow the Web UI setup to complete so that xtag is given a value.
Here's an example:
import 'dart:async';
import 'dart:html';
import 'package:web_ui/web_ui.dart';
main() {
Timer.run(() {
var myElement = query('#my-element').xtag;
myElement.startAnimation();
});
}
This will get better with the ability to import components, directly subclass Element and maybe some lifecycle events that guarantee that you get the correct class back from a query(). This is what the exemple should look like in the future:
import 'dart:async';
import 'dart:html';
import 'package:web_ui/web_ui.dart';
import 'package:my_app/my_element.dart';
main() {
MyElement myElement = query('#my-element');
myElement.startAnimation();
}

Resources