Advertisement
Superloup10

Untitled

Oct 30th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. perform(sender: UserInfo, ctx: CommandContext, querySession: QuerySession, resolve: () => void, reject: () => void): void {
  2.         const embed: RichEmbed = new RichEmbed();
  3.         const channels: TextChannel[] = [
  4.             ctx.getDiscordClient().channels.find(value => (value as TextChannel).name === ctx.getConfig().get("channels.aide_modding")) as TextChannel,
  5.             ctx.getDiscordClient().channels.find(value => (value as TextChannel).name === ctx.getConfig().get("channels.recrutement")) as TextChannel,
  6.             ctx.getDiscordClient().channels.find(value => (value as TextChannel).name === ctx.getConfig().get("channels.flood")) as TextChannel
  7.         ];
  8.         const channel: TextChannel = ctx.getDiscordClient().channels.find(value => (value as TextChannel).name === ctx.getConfig().get('channels.rules')) as TextChannel;
  9.  
  10.         async function clear() {
  11.             let fetched;
  12.             do {
  13.                 fetched = await channel.fetchMessages({limit: 1});
  14.                 await channel.bulkDelete(fetched);
  15.             } while (fetched.size >= 2);
  16.         }
  17.  
  18.         clear().then(() => ctx.getLogger().info("Delete all message with success"));
  19.         embed.setTitle(":scroll: RÈGLES DU DISCORD DE MINECRAFT FORGE FRANCE");
  20.         embed.setDescription("───────────────────────────────────");
  21.         embed.setColor(INFO_COLOR);
  22.         embed.setThumbnail("https://cdn.discordapp.com/attachments/270667098143981589/347773487093383189/avatar_128x128_transparent.png");
  23.  
  24.         if (fs.existsSync("règle.txt")) {
  25.             const fileContent = fs.readFileSync("règle.txt").toString().split("\n");
  26.             for (let i = 0; i < fileContent.length; i++) {
  27.                 if (fileContent[i].match(/#([a-zA-Z-]+)/g)) {
  28.                     fileContent[i] = fileContent[i].replace(/#([a-zA-Z-]+)/g, (match, name) => {
  29.                         let temp: string = "";
  30.                         for (const value of channels) {
  31.                             if (value.name === name) {
  32.                                 temp = value.toString();
  33.                             }
  34.                         }
  35.                         return temp;
  36.                     });
  37.                 }
  38.                 embed.addField(`${i + 1}.`, fileContent[i]);
  39.             }
  40.  
  41.             channel.send(embed);
  42.         }
  43.         resolve();
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement