Discord.js removerole not a function - discord.js

person.removerole(mainrole.id);
person.addrole(muterole.id);
message.channel.send(`#${person.user.tag} has now been muted for ${ms(ms(time))}`);
setTimeout(function(){
person.addrole(mainrole.id);
person.removerole(muterole.id);
message.channel.send(`#${person.user.tag} has been unmuted!`)
}, ms(time));

addrole() and removerole() are not valid.
Use roles.add() and roles.remove()

Related

How to write wait condition for browser.title()?

I'm looking for a wait condition to get the browser title. Currently, i use browser.getTitle() to get the browser title. Somehow, my script times out waiting to get the browser title. I can't use browser.sleep in this case. How do i achieve this by using browser.wait() condition?
Any help with be greatly appreciated. Thanks!
This seems like a perfect use case for the titleIs ExpectedCondition. Could you give it a try?
var EC = protractor.ExpectedConditions;
browser.wait(EC.titleIs('foo'), 5000, 'Title not "foo" after 5 seconds');
function waitForTitle(expectedTitle: string, time: number) {
return browser.wait(() => {
return browser.getTitle().then((currentTitle) => {
return currentTitle === expectedTitle;
});
}, time);
}
You just need to remember that time is given in ms.

browser closure confirmation on ext.net

What I want to do is the following
window.onbeforeunload = function (e) {
return 'Dialog text here.';
Ext.Msg.confirm("ConfirmaciĆ³n", "Seguro que quieres salir", function (btnText) {
if (btnText === "yes") {
App.direct.RegistrarAbandono();
}
}, this);
};
that is, I want that if the person leaves the browser to be able to delete or do some action from the server and notify the person who will have some consequences for avandonar the form.
thank you very much
Try using below code:
Ext.EventManager.on(window, "beforeunload", function (e) {
Write your code here
}, this, {});

d3 datamaps US state map redraw only individual state when clicked

I'm using the datamaps library to display the US map using d3.js
I would like to only display a state when it is clicked. How can I do this using d3 or datamaps library?
var map = new Datamap({
element: document.getElementById('container'),
done: function(datamap) {
datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
alert(geography.properties.name);
});
}
});
I'm thinking about using the done callback (example shown above) to set the projection of the datamap. But it doesn't seem to be working at the moment.
Something like this:
datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
datamap.svg.selectAll('.datamaps-subunit')
.style('display', function(d){
return d.id === geography.id ? 'initial' : 'none'
});
datamap.svg.selectAll('.datamaps-arc')
.style('display', function(d){
//
});
datamap.svg.selectAll('.datamaps-bubble')
.style('display', function(d){
//
});
});

alert box isn't raised in the code, its written for conform msg

function
FController($scope,$window)
{
$scope.persons=[];
$window.alert("hi in body");
$scope.saveIt = function () {
$window.alert("alert in save");
//$scope.persons.push({ });
};
}
<button id="bt1" ng-Click="saveIt()">Save</button>
$window.alert is not correct. window.alert is. You don't need to include $window in your dependency injections.

Angularjs wait until

I have:
$scope.bounds = {}
And later in my code:
$scope.$on('leafletDirectiveMap.load', function(){
console.log('runs');
Dajaxice.async.hello($scope.populate, {
'west' : $scope.bounds.southWest.lng,
'east': $scope.bounds.northEast.lng,
'north' : $scope.bounds.northEast.lat,
'south': $scope.bounds.southWest.lat,
});
});
The bounds as you can see at the begging they are empty but they are loaded later (some milliseconds) with a javascript library (leaflet angular). However the $scope.$on(...) runs before the bounds have been set so the 'west' : $scope.bounds.southWest.lng, returns an error with an undefined variable.
What I want to do is to wait the bounds (southWest and northEast) to have been set and then run the Dajaxice.async.hello(...).
So I need something like "wait until bounds are set".
You can use $watch for this purpose, something like this:
$scope.$on('leafletDirectiveMap.load', function(){
$scope.$watch( "bounds" , function(n,o){
if(n==o) return;
Dajaxice.async.hello($scope.populate, {
'west' : $scope.bounds.southWest.lng,
'east': $scope.bounds.northEast.lng,
'north' : $scope.bounds.northEast.lat,
'south': $scope.bounds.southWest.lat,
});
},true);
});
If you want to do this every time the bounds change, you should just use a $watch expression:
$scope.$watch('bounds',function(newBounds) {
...
});
If you only want to do it the first time the bounds are set, you should stop watching after you've done your thing:
var stopWatching = $scope.$watch('bounds',function(newBounds) {
if(newBounds.southWest) {
...
stopWatching();
}
});
You can see it in action here: http://plnkr.co/edit/nTKx1uwsAEalc7Zgss2r?p=preview

Resources