Advertisement
NaroxEG

ads bot

Aug 29th, 2022 (edited)
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.09 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import time
  4. from datetime import datetime, timedelta
  5. from discord.ext.commands.core import cooldown
  6.  
  7. # paste your bot token & prefix
  8. token = ""
  9. prefix = "$"
  10.  
  11. client = commands.Bot(command_prefix=prefix, case_insensitive=True)
  12.  
  13.  
  14. @client.event
  15. async def on_ready():
  16.     await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="ADS"))
  17.     print(f"Connected to discord as {client.user}")
  18.  
  19.  
  20. on_cooldown = {}  # Dictionary with user IDs as keys and datetime as values
  21. use_cooldown = 3600  # cooldown of the command in seconds
  22.  
  23.  
  24. @client.command()
  25. @commands.dm_only()
  26. async def adf(ctx, *, link=None):
  27.     # channel where you want the ad to be posted
  28.     # replace this id with ur channel id
  29.     cid = 890196692304007188
  30.     # Put your first or nick name here
  31.     creator_name = "Narox"
  32.     channel = client.get_channel(cid)
  33.     if link == None:
  34.         embed = discord.Embed(color=0xe02929)
  35.         embed.add_field(name="AD - ERROR",
  36.                         value="Please insert your discord invite link", inline=False)
  37.         embed.set_footer(text=f"Created by {creator_name}")
  38.         await ctx.reply(embed=embed)
  39.     elif link.startswith('https://discord.gg') == True or link.startswith('discord.gg/') == True:
  40.         author = ctx.author.id
  41.         try:
  42.             # calculate cooldown time
  43.             last_use = datetime.now() - on_cooldown[author]
  44.         except KeyError:
  45.             # the command is used for the first time , or bot was restarted
  46.             last_use = None
  47.             on_cooldown[author] = datetime.now()
  48.         if last_use is None or last_use.seconds > use_cooldown:
  49.             on_cooldown[author] = datetime.now()
  50.             embed = discord.Embed(color=0x29e047)
  51.             embed.add_field(
  52.                 name="Success", value=f"Successfully sent your FREE AD to <#{cid}>", inline=False)
  53.             embed.set_footer(text=f"Created by {creator_name}")
  54.             await ctx.reply(embed=embed)
  55.             print(f"{ctx.author.name}#{ctx.author.discriminator} > Shared an AD!")
  56.             embed2 = discord.Embed(color=0x29e047)
  57.             embed2.add_field(
  58.                 name=f"AD By {ctx.author.name}#{ctx.author.discriminator}", value=f"{link}", inline=False)
  59.             embed2.set_footer(text=f"Created by {creator_name}")
  60.             await channel.send(embed=embed2)
  61.         else:
  62.             embed = discord.Embed(color=0xe02929)
  63.             embed.add_field(
  64.                 name="AD - ERROR", value=f"You can only use this command once per hour , try again later!", inline=False)
  65.             msg_sd = await ctx.reply(embed=embed)
  66.             time.sleep(5)
  67.             await msg_sd.delete()
  68.             await ctx.message.delete()
  69.     else:
  70.         embed = discord.Embed(color=0xe02929)
  71.         embed.add_field(name="AD - ERROR",
  72.                         value="Only discord links are allowed", inline=False)
  73.         embed.set_footer(text=f"Created by {creator_name}")
  74.         await ctx.reply(embed=embed)
  75.  
  76.  
  77. client.run(token)
  78.  
  79.  
  80. # https://www.youtube.com/c/NaroxEG
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement