Advertisement
Khanmanan2021

Start.js/server.js

Mar 31st, 2021
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1.  
  2. Start.js
  3.  
  4.  
  5.  
  6. const { MessageEmbed } = require('discord.js')
  7. const ms = require('ms');
  8. module.exports = {
  9. name: "start",
  10. description: "Creating giveaway",
  11. accessableby: "Administrator",
  12. category: "giveaway",
  13. aliases: ["giveaway-start"],
  14. usage: '<channel> <duration> <winners>, <prize>',
  15. run: async (bot, message, args) => {
  16. if(!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.roles.cache.some((r) => r.name === "Giveaways")){
  17. return message.channel.send(':x: You need to have the manage messages permissions to start giveaways.');
  18. }
  19.  
  20. // Giveaway channel
  21. let giveawayChannel = message.mentions.channels.first();
  22. // If no channel is mentionned
  23. if(!giveawayChannel){
  24. return message.channel.send(':x: You have to mention a valid channel!');
  25. }
  26.  
  27. // Giveaway duration
  28. let giveawayDuration = args[1];
  29. // If the duration isn't valid
  30. if(!giveawayDuration || isNaN(ms(giveawayDuration))){
  31. return message.channel.send(':x: You have to specify a valid duration!');
  32. }
  33.  
  34. // Number of winners
  35. let giveawayNumberWinners = args[2];
  36. // If the specified number of winners is not a number
  37. if(isNaN(giveawayNumberWinners) || (parseInt(giveawayNumberWinners) <= 0)){
  38. return message.channel.send(':x: You have to specify a valid number of winners!');
  39. }
  40.  
  41. // Giveaway prize
  42. let giveawayPrize = args.slice(3).join(' ');
  43. // If no prize is specified
  44. if(!giveawayPrize){
  45. return message.channel.send(':x: You have to specify a valid prize!');
  46. }
  47.  
  48. // Start the giveaway
  49. bot.giveawaysManager.start(giveawayChannel, {
  50. // The giveaway duration
  51. time: ms(giveawayDuration),
  52. // The giveaway prize
  53. prize: giveawayPrize,
  54. // The giveaway winner count
  55. winnerCount: giveawayNumberWinners,
  56. // Who hosts this giveaway
  57. hostedBy: message.author,
  58. // Messages
  59. messages: {
  60. giveaway: "🎉🎉 **GIVEAWAY** 🎉🎉",
  61. giveawayEnded: "🎉🎉 **GIVEAWAY ENDED** 🎉🎉",
  62. timeRemaining: "Time remaining: **{duration}**!",
  63. inviteToParticipate: "React with 🎉 to participate!",
  64. winMessage: "Congratulations, {winners}! You won **{prize}**!",
  65. embedFooter: "Giveaways",
  66. noWinner: "Giveaway cancelled, no valid participations.",
  67. hostedBy: "Hosted by: {user}",
  68. winners: "winner(s)",
  69. endedAt: "Ended at",
  70. units: {
  71. seconds: "seconds",
  72. minutes: "minutes",
  73. hours: "hours",
  74. days: "days",
  75. pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
  76. }
  77. }
  78. });
  79.  
  80. message.channel.send(`Giveaway started in ${giveawayChannel}!`);
  81.  
  82. }
  83. }
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. Paste these in srver.js ↓
  105.  
  106.  
  107.  
  108. const { MessageEmbed } = require('discord.js')
  109. const ms = require('ms');
  110. module.exports = {
  111. name: "start",
  112. description: "Creating giveaway",
  113. accessableby: "Administrator",
  114. category: "giveaway",
  115. aliases: ["giveaway-start"],
  116. usage: '<channel> <duration> <winners>, <prize>',
  117. run: async (bot, message, args) => {
  118. if(!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.roles.cache.some((r) => r.name === "Giveaways")){
  119. return message.channel.send(':x: You need to have the manage messages permissions to start giveaways.');
  120. }
  121.  
  122. // Giveaway channel
  123. let giveawayChannel = message.mentions.channels.first();
  124. // If no channel is mentionned
  125. if(!giveawayChannel){
  126. return message.channel.send(':x: You have to mention a valid channel!');
  127. }
  128.  
  129. // Giveaway duration
  130. let giveawayDuration = args[1];
  131. // If the duration isn't valid
  132. if(!giveawayDuration || isNaN(ms(giveawayDuration))){
  133. return message.channel.send(':x: You have to specify a valid duration!');
  134. }
  135.  
  136. // Number of winners
  137. let giveawayNumberWinners = args[2];
  138. // If the specified number of winners is not a number
  139. if(isNaN(giveawayNumberWinners) || (parseInt(giveawayNumberWinners) <= 0)){
  140. return message.channel.send(':x: You have to specify a valid number of winners!');
  141. }
  142.  
  143. // Giveaway prize
  144. let giveawayPrize = args.slice(3).join(' ');
  145. // If no prize is specified
  146. if(!giveawayPrize){
  147. return message.channel.send(':x: You have to specify a valid prize!');
  148. }
  149.  
  150. // Start the giveaway
  151. bot.giveawaysManager.start(giveawayChannel, {
  152. // The giveaway duration
  153. time: ms(giveawayDuration),
  154. // The giveaway prize
  155. prize: giveawayPrize,
  156. // The giveaway winner count
  157. winnerCount: giveawayNumberWinners,
  158. // Who hosts this giveaway
  159. hostedBy: message.author,
  160. // Messages
  161. messages: {
  162. giveaway: "🎉🎉 **GIVEAWAY** 🎉🎉",
  163. giveawayEnded: "🎉🎉 **GIVEAWAY ENDED** 🎉🎉",
  164. timeRemaining: "Time remaining: **{duration}**!",
  165. inviteToParticipate: "React with 🎉 to participate!",
  166. winMessage: "Congratulations, {winners}! You won **{prize}**!",
  167. embedFooter: "Giveaways",
  168. noWinner: "Giveaway cancelled, no valid participations.",
  169. hostedBy: "Hosted by: {user}",
  170. winners: "winner(s)",
  171. endedAt: "Ended at",
  172. units: {
  173. seconds: "seconds",
  174. minutes: "minutes",
  175. hours: "hours",
  176. days: "days",
  177. pluralS: false // Not needed, because units end with a S so it will automatically removed if the unit value is lower than 2
  178. }
  179. }
  180. });
  181.  
  182. message.channel.send(`Giveaway started in ${giveawayChannel}!`);
  183.  
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement