Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. registerPlugin({
  2. name: 'Simple Welcome Sound',
  3. version: '1.0',
  4. description: 'Greet users with custom sound.',
  5. author: 'R3flex <r3flexmlg@gmail.com>',
  6. vars: {
  7. defaultVolume: {
  8. title: 'Default Sound Volume (30 is default, 0-100)',
  9. type: 'string',
  10. placeholder: '30'
  11. },
  12. soundArray: {
  13. title: 'Configuration',
  14. type: 'array',
  15. vars: [
  16. {
  17. name: 'serverGroupID',
  18. indent: 1,
  19. title: 'Server Group',
  20. type: 'number',
  21. placeholder: '1'
  22. },
  23. {
  24. name: 'SkipGroup',
  25. title: 'Skip the server group option.',
  26. type: 'checkbox',
  27. placeholder: '1'
  28. },
  29. {
  30. name: 'SoundVolume',
  31. title: 'Sound Volume (30 is default, 0-100)',
  32. type: 'string',
  33. placeholder: '30'
  34. },
  35. {
  36. name: 'Sound',
  37. indent: 1,
  38. title: 'Welcome Sound(yt link or track ID)',
  39. type: 'string',
  40. placeholder: '1'
  41. },
  42. {
  43. name: 'soundType',
  44. title: 'Sound Type',
  45. type: 'select',
  46. options: [
  47. 'Track ID',
  48. 'Youtube Link(requires yt-dl)'
  49. ]
  50. }
  51. ]
  52. }
  53.  
  54. }
  55. }, function main(sinusbot, config) {
  56.  
  57. var event = require('event');
  58. var engine = require('engine');
  59. var backend = require('backend');
  60. var media = require('media');
  61.  
  62. var allTracks = [];
  63.  
  64. for (var i = config.soundArray.length - 1; i >= 0; i--) {
  65. allTracks.push(config.soundArray[i]);
  66. }
  67.  
  68. for (var i = 0; i < allTracks.length; i++) {
  69. if (allTracks[i].SkipGroup) {
  70. var spliced = allTracks.splice(i,1);
  71. allTracks.push(spliced[0]);
  72. }
  73. }
  74.  
  75. event.on('clientMove', function(ev) {
  76. if(!ev.fromChannel) {
  77. for (var i = 0; i < allTracks.length; i++) {
  78. if (!isNotInServerGroup(ev.client.getServerGroups(), allTracks[i].serverGroupID) || allTracks[i].SkipGroup) {
  79. var currentVol = getVolume();
  80. if (config.soundArray[i].SoundVolume > currentVol) {
  81. setVolume(config.soundArray[i].SoundVolume);
  82. }
  83.  
  84. if (allTracks[i].soundType == 0) {
  85. media.playURL(allTracks[i].Sound);
  86. break;
  87. }
  88.  
  89. if (allTracks[i].soundType == 1) {
  90. media.yt(allTracks[i].Sound);
  91. break;
  92. }
  93.  
  94. }
  95. setVolume(config.defaultVolume);
  96. }
  97. }
  98. });
  99.  
  100. function isNotInServerGroup(user_servergroups, servergroup_id) {
  101.  
  102. for(var count = 0; count < user_servergroups.length; count++) {
  103.  
  104. if(user_servergroups[count].id() == servergroup_id) {
  105.  
  106. return false;
  107.  
  108. }
  109.  
  110. }
  111.  
  112. return true;
  113.  
  114. }
  115.  
  116. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement