Advertisement
Guest User

rip

a guest
Feb 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1.  
  2. const Discord = require('discord.js');
  3. const client = new Discord.Client();
  4. const ytdl = require('ytdl-core');
  5. const opus = require('opusscript');
  6.  
  7. client.on('ready', () => {
  8. console.log('Saya siap digunakan');
  9. client.user.setActivity(`Test Watching`, {Type: 'WATCHING'})
  10. });
  11.  
  12.  
  13. const prefix = 'Dv.'
  14.  
  15.  
  16. client.on('message', async message => {
  17.  
  18. const args = message.content.slice(prefix.length).trim().split(/ +/g);
  19. const command = args.shift().toLowerCase();
  20.  
  21. if (message.content === "halo") {
  22. message.channel.send('Hello world');
  23. }
  24. if (message.content === "indonesia") {
  25. message.channel.send(':flag_id: ');
  26. }
  27.  
  28.  
  29. if (command === "play") {
  30. message.member.voiceChannel.join().then(connection => {
  31. console.log('Music sedang berjalan')
  32. const dispatcher = connection.playStream(ytdl(`${args[0]}`));
  33. connection.dispatcher.setVolumeLogaritchmic(1);
  34.  
  35. });
  36. message.channel.send('**Berhasil memutar musik 🎶**')
  37. }
  38.  
  39. if (command === "leave") {
  40. message.member.voiceChannel.leave()
  41. message.channel.send('Berhasil di keluarkan')
  42. }
  43.  
  44. if (command === "help") {
  45.  
  46. let embed = new Discord.RichEmbed()
  47. .setTitle('Command Help')
  48. .addField('Music 🎶','`Dv.play` `Dv.leave`')
  49. .setFooter('Belajar Coding Discord bot.')
  50. .setColor('BLUE')
  51.  
  52. message.channel.send(embed);
  53.  
  54. }
  55.  
  56. if (command === "botinfo") {
  57.  
  58. let botembed = new Discord.RichEmbed()
  59. .setTitle('📣 BOT INFO')
  60. .setColor('BLUE')
  61. .addField('📰 Nama Bot:', client.user.username, true)
  62. .addField('⏲ Dibuat Waktu:', client.user.createdAt, true)
  63. .addField('🛰 Dibuat Oleh:','DevFian',true)
  64. .setFooter('© Copyright - Simple Coding.')
  65.  
  66. message.channel.send(botembed);
  67. }
  68.  
  69. if (command === "avatar") {
  70.  
  71. let user = message.mentions.users.first() || message.author;
  72.  
  73. let embed = new Discord.RichEmbed()
  74. .setTitle('Avatar Command')
  75. .setImage(user.displayAvatarURL) // menunjukan avatar url yang di input oleh embed dan menjadikan gambar.
  76. .setColor('BLUE')
  77.  
  78. message.channel.send(embed)
  79. }
  80.  
  81. if (command === "ping") {
  82.  
  83. let ping = new Date()
  84. let pong = new Date() - message.createdAt;
  85. let wait = await message.channel.send("Wait...");
  86. let embed = new Discord.RichEmbed()
  87. .setTitle(`${client.user.username} Ping`)
  88. .setDescription(`API: **\`${Math.floor(client.ping)}\`ms**\nLatency: **\`${pong}\`ms**`)
  89. return wait.edit(embed)
  90. }
  91.  
  92. if (command === 'cat') {
  93. const superagent = require('superagent');
  94. let { body } = await superagent.get('http://aws.random.cat/meow')
  95. let meow = new Discord.RichEmbed()
  96. .setTitle(`Meow 😺`)
  97. .setColor("RANDOM")
  98. .setImage(body.file)
  99. message.channel.send(meow)
  100. }
  101.  
  102. // Command Say
  103. if (command === 'say' || command === 'chat') {
  104. let chat = args.join(" ")
  105. if (!chat) return message.channel.send(`Kasih saya Text!`)
  106. return message.delete()
  107. await message.channel.send(chat)
  108. }
  109.  
  110. //command Restart Bot - tanpa edit watch.json - Process.exit
  111. if (command === 'restart') {
  112. if(message.author.id !== '467298098096635934') return message.channel.send('Kamu bukan pemilik, tidak ada akses.');
  113. message.channel.send('Bot Telah di restart').then(() => {
  114. process.exit(1);
  115. })
  116.  
  117. }
  118.  
  119. });
  120.  
  121. /* Chat ROOM :v
  122.  
  123.  
  124.  
  125.  
  126. */
  127.  
  128. client.login(process.env.TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement