Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registerPlugin({
- name: 'Simple Welcome Sound',
- version: '1.0',
- description: 'Greet users with custom sound.',
- author: 'R3flex <r3flexmlg@gmail.com>',
- vars: {
- defaultVolume: {
- title: 'Default Sound Volume (30 is default, 0-100)',
- type: 'string',
- placeholder: '30'
- },
- soundArray: {
- title: 'Configuration',
- type: 'array',
- vars: [
- {
- name: 'serverGroupID',
- indent: 1,
- title: 'Server Group',
- type: 'number',
- placeholder: '1'
- },
- {
- name: 'SkipGroup',
- title: 'Skip the server group option.',
- type: 'checkbox',
- placeholder: '1'
- },
- {
- name: 'SoundVolume',
- title: 'Sound Volume (30 is default, 0-100)',
- type: 'string',
- placeholder: '30'
- },
- {
- name: 'Sound',
- indent: 1,
- title: 'Welcome Sound(yt link or track ID)',
- type: 'string',
- placeholder: '1'
- },
- {
- name: 'soundType',
- title: 'Sound Type',
- type: 'select',
- options: [
- 'Track ID',
- 'Youtube Link(requires yt-dl)'
- ]
- }
- ]
- }
- }
- }, function main(sinusbot, config) {
- var event = require('event');
- var engine = require('engine');
- var backend = require('backend');
- var media = require('media');
- var allTracks = [];
- for (var i = config.soundArray.length - 1; i >= 0; i--) {
- allTracks.push(config.soundArray[i]);
- }
- for (var i = 0; i < allTracks.length; i++) {
- if (allTracks[i].SkipGroup) {
- var spliced = allTracks.splice(i,1);
- allTracks.push(spliced[0]);
- }
- }
- event.on('clientMove', function(ev) {
- if(!ev.fromChannel) {
- for (var i = 0; i < allTracks.length; i++) {
- if (!isNotInServerGroup(ev.client.getServerGroups(), allTracks[i].serverGroupID) || allTracks[i].SkipGroup) {
- var currentVol = getVolume();
- if (config.soundArray[i].SoundVolume > currentVol) {
- setVolume(config.soundArray[i].SoundVolume);
- }
- if (allTracks[i].soundType == 0) {
- media.playURL(allTracks[i].Sound);
- break;
- }
- if (allTracks[i].soundType == 1) {
- media.yt(allTracks[i].Sound);
- break;
- }
- }
- setVolume(config.defaultVolume);
- }
- }
- });
- function isNotInServerGroup(user_servergroups, servergroup_id) {
- for(var count = 0; count < user_servergroups.length; count++) {
- if(user_servergroups[count].id() == servergroup_id) {
- return false;
- }
- }
- return true;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement