Related
I try to create a channel but i always have an error.
I don't find how to fix it.
Don't pay attention to the "req[0]." in "code" it comes from the database, no link with the problem because it works in v13
"It looks like your post is mostly code; please add some more details." I don't know what can I have for more details. haha.
Sorry, English is not my native langage.
error :
throw new DiscordAPIError.DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
at SequentialHandler.runRequest (/root/project/node_modules/#discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:293:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/root/project/node_modules/#discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14)
at async REST.request (/root/project/node_modules/#discordjs/rest/dist/lib/REST.cjs:52:22)
at async GuildChannelManager.create (/root/new ascension/node_modules/discord.js/src/managers/GuildChannelManager.js:145:18) {
rawError: {
code: 50035,
errors: {
name: {
_errors: [
{
code: 'BASE_TYPE_REQUIRED',
message: 'This field is required'
}
]
}
},
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/guilds/873350117124628552/channels',
requestBody: {
files: undefined,
json: {
name: undefined,
topic: undefined,
type: undefined,
nsfw: undefined,
bitrate: undefined,
user_limit: undefined,
parent_id: undefined,
position: undefined,
permission_overwrites: undefined,
rate_limit_per_user: undefined,
rtc_region: undefined,
video_quality_mode: undefined
}
}
}
Node.js v18.3.0
code :
action.guild.channels.create(`hello`, {
type: "GUILD_TEXT",
parent: cat[0].ID,
permissionOverwrites: [
{
id: bot.user.id,
allow: ['VIEW_CHANNEL', "MANAGE_CHANNELS"]
},
{
id: action.user.id,
allow: ["VIEW_CHANNEL"]
},
{
id: req[0].ID,
deny: ["VIEW_CHANNEL"]
},
{
id: staff[0].ID,
allow: ["VIEW_CHANNEL"]
}
]
})
You can't set the type of the channel using a string anymore, you have to use the new ChannelType enum. You can import it from the discord.js library, and once you've done that, creating a channel would look something like this:
guild.channels.create({
name: "hello",
type: ChannelType.GuildText,
parent: cat[0].ID,
// your permission overwrites or other options here
});
Also make sure that all of your arguments are being passed in only one object, and the name isn't a separate argument.
I need implement a javascript project that creates a new google meet according to the user signed in and adds the event to the calendar and gets the url of the google meet. How can i create a new google meet using Google Calendar API in JS.
Answer:
You need to use the conferenceData.createRequest parameter of the Events resource when creating a Calendar.Events: insert request to add a Meet link to a Calendar Event.
More Information:
As per the documention for Events: insert and the Event resource reperesentation:
conferenceDataVersion: integer
Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0. Acceptable values are 0 to 1, inclusive.
conferenceData.createRequest: nested object
A request to generate a new conference and attach it to the event. The data is generated asynchronously. To see whether the data is present check the status field.
Either conferenceSolution and at least one entryPoint, or createRequest is required.
conferenceData.createRequest.conferenceSolutionKey.type: string
The conference solution type.
If a client encounters an unfamiliar or empty type, it should still be able to display the entry points. However, it should disallow modifications.
The possible values are:
"eventHangout" for Hangouts for consumers (http://hangouts.google.com)
"eventNamedHangout" for classic Hangouts for G Suite users (http://hangouts.google.com)
"hangoutsMeet" for Google Meet (http://meet.google.com)
"addOn" for 3P conference providers
conferenceData.createRequest.requestId: string
The client-generated unique ID for this request.
Clients should regenerate this ID for every new request. If an ID provided is the same as for the previous request, the request is ignored.
With this information we can generate a Calendar Event creation request with a Meet link as the conference solution.
Example Request:
gapi.client.calendar.events.insert({
"calendarId": "primary",
"conferenceDataVersion": 1,
"resource": {
"end": {
"date": "2020-10-24"
},
"start": {
"date": "2020-10-23"
},
"conferenceData": {
"createRequest": {
"conferenceSolutionKey": {
"type": "hangoutsMeet"
},
"requestId": "some-random-string"
}
},
"summary": "titles are cool"
}
});
NB: In order for a Meet link to be generated, you must set conferenceData.createRequest.requestId to any random string. For each new meet link you wish to create, you must use a different string in the request.
References:
Events: insert | Calendar API | Google Developers
Events | Calendar API | Google Developers
If you aren't using the node library, the request with axios is below. I did not realize from the answer above conferenceDataVersion is a query param.
let event = {
summary: "some text",
location: "some text",
description: "some text",
start: {
dateTime: start,
timeZone: timeZone,
},
end: {
dateTime: end,
timeZone: timeZone,
},
recurrence: [],
attendees: [
{ email: 'johndoe#whatever.com' },
],
reminders: {
useDefault: true,
},
conferenceData: {
createRequest: {
conferenceSolutionKey: {
type: 'hangoutsMeet',
},
requestId: 'somerequestid',
},
},
};
const createEventRequest = await axios({
url: `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events?conferenceDataVersion=1`,
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
},
data: event,
});
Extending #Brit's comment in googleapis npm package the way it should be executed will be
let response = await calendar.events.insert({
auth: auth,
calendarId: calendarId,
resource: event,
conferenceDataVersion: 1
});
with event as
let event = {
'summary': `Appointment.`,
'description': `Description`,
'start': {
'dateTime': dateTime['start'],
'timeZone': 'Asia/Kolkata'
},
'end': {
'dateTime': dateTime['end'],
'timeZone': 'Asia/Kolkata'
},
'attendees': [
{'email': '...#gmail.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
"conferenceData": {
"createRequest": {
"conferenceSolutionKey": {
"type": "hangoutsMeet"
},
"requestId": "JksKJJSK1KJSK"
}
},
};
I am using Flowplayer(in Mean js audio streaming project) for RTMP audio streaming with Wowza streaming engine software and using below service of angular js.
app.service('flowPlayerService', ['$cookies','constant',function ($cookies,constant) {
player: null,
currentTitle:'',
constructPlaylist: function (playlist) {
var currentObj = this;
this.player = flowplayer("flashPlayer", "lib/flowplayer/flowplayer-3.2.18.swf", {
playlist:playlist,
onBegin: function(talk){
console.log('clip changed');
},
onFail:function(){
//alert('loading failed');
},
onFinish:function(){
console.log('finisheds');
},
// engine:'html5',
// Specify the location of the RTMP plugin.
plugins: {
rtmp: {
url: 'lib/flowplayer/flowplayer.rtmp-3.2.13.swf',
netConnectionUrl: 'rtmp://10.10.3.11/vod'
},
controls: {
autoHide: 'never',
url: 'lib/flowplayer/flowplayer.controls-3.2.16.swf',
tooltips: {
buttons: true,
fullscreen: false,
pause: 'Continue playing',
},
playlist: true,
fullscreen:false,
},
dock: {
enabled:false,
gap: 5,
autoHide: false
}
},
onMouseOut:function(){
console.log('mouse out');
}
//canvas: {backgroundGradient: 'none'}
});
console.log(this.player);
//this.player = flowplayer();
},
}
While playing single track it is working fine.But when I try to run playlist first track plays file but when first track finished it gives error like:-
VM36229:1 [ERROR] time 13:51:35.968 :: 201, Unable to load stream or clip file, cannot play video: Error #2154, clip: '[Clip] 'mp3:02 Jashn-E-Bahaara-1469775940586.mp3''
below playlist array example:-
[{
url:"mp3:track.mp3",
provider:"rtmp",
title:'track title'
},
{
url:"mp3:track1.mp3",
provider:"rtmp",
title:'track title1'
}
]
please help.
Passing the "duration" to clip objects resolve this issue.
Trying to display Milestone for each release, but when trying to create DataStore for Milestone getting error
Uncaught Rally.data.ModelFactory.getModel(): Could not find registered factory for type: milestone
below is my code any ideas or suggestions on this
_getMileStones: function(startDate, endDate, project_id) {
var startDateFilter = Ext.create('Rally.data.QueryFilter', {
property: 'TargetDate',
operator: '>',
value: startDate
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '<',
value: endDate
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '!=',
value: null
});
startDateFilter = startDateFilter.and({
property: 'TargetDate',
operator: '!=',
value: null
});
var filters = startDateFilter;
Ext.create('Rally.data.wsapi.Store',{
model: 'milestone',
autoLoad: true,
filters: filters,
context: {
project: project_id,
projectScopeDown: true,
projectScopeUp: false
},
fetch: ['Name','FormattedID','DisplayColor'],
listeners: {
load: function(store,records) {
console.log("records values", records);
}
}
}, this);
},
The current stable rc3 release candidate of AppSDK2 predates milestones. They are not available in rc3. When I use rc3 I get the same error you get. If I switch to "x", in the app's config file, and use rab build to rebuild the app, the error goes away:
{
"name": "myapp",
"className": "CustomApp",
"server": "https://rally1.rallydev.com",
"sdk": "x",
"javascript": [
"App.js"
],
"css": [
"app.css"
]
}
Generally it is not recommend using "x" because it is constantly changes. It is not a stable version. But as long as you know that, you may use "x". The AppSDK next release may not be too far in the future, and it will include support for Milestones.
UPDATE: AppSDK2.0 GA has not been announced yet, but it is expected to be released soon. If you use "sdk":"2.0" you get Milestone data.
"x" returns Milestones, but it is a head version that is subject to constant changes. 2.0rc3 does not have Milestones.
You may choose to use 2.0 even though it is not formally available yet.
This app example:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.wsapi.Store',{
model: 'milestone',
autoLoad: true,
fetch: ['Name'],
listeners: {
load: function(store,records) {
console.log("records values", records);
}
}
}, this);
}
});
Along with this config:
{
"name": "milestones",
"className": "CustomApp",
"server": "https://rally1.rallydev.com",
"sdk": "2.0",
"javascript": [
"App.js"
],
"css": [
"app.css"
]
}
will return milestone data:
I followed this tutorial to create a project with Loopback and AngularJs. https://github.com/strongloop/loopback-example-angular
Now, I have an application with:
HTML files (with Bootstrap)
AngularJS controllers
AngularJS service (generated with syntax lb-ng server/server.js client/js/services/lb-services.js)
Model (located in ./common folder)
MongoDB backend
The model "Device" is defined in ./common/models/device.js
module.exports = function(Device) {
};
And in ./common/models/device.json
{
"name": "Device",
"base": "PersistedModel",
"idInjection": true,
"properties": {
"name": {
"type": "string",
"required": true
},
"description": {
"type": "string",
"required": true
},
"category": {
"type": "string",
"required": true
},
"initialDate": {
"type": "date"
},
"initialPrice": {
"type": "number",
"required": true
},
"memory": {
"type": "number"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
In the "AddDeviceController", I have an initialization part with:
$scope.device = new DeviceToBuy({
name: '',
description: '',
category: '',
initialPrice: 0,
memory: 8
initialDate: Date.now()
});
And I am able to save the $scope.device when executing the following method:
$scope.save = function() {
Device.create($scope.device)
.$promise
.then(function() {
console.log("saved");
$scope.back(); // goto previous page
}, function (error) {
console.log(JSON.stringify(error));
});
}
When everything is valid, the model is saved in the backend. If something is not valid in the $scope.device, I receive an error from my backend. So everything is working fine.
Now, I would like to use the model to perform client-side validation before sending my model to the backend and put some "error-class" on the bootstrap controls.
I tried something in the $scope.save function before sending to the backend:
if ($scope.device.isValid()) {
console.log("IsValid");
} else {
console.log("Not Valid");
}
But I get an exception "undefined is not a function" --> isValid() doesn't exist.
And I cannot find any example on how to execute this client-side validation.
LoopBack models are unopinionated and therefore do not provide client side validation out-of-box. You should use Angular validation mechanisms before calling $save.