Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import time
- from datetime import datetime, timedelta
- from discord.ext.commands.core import cooldown
- # paste your bot token & prefix
- token = ""
- prefix = "$"
- client = commands.Bot(command_prefix=prefix, case_insensitive=True)
- @client.event
- async def on_ready():
- await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="ADS"))
- print(f"Connected to discord as {client.user}")
- on_cooldown = {} # Dictionary with user IDs as keys and datetime as values
- use_cooldown = 3600 # cooldown of the command in seconds
- @client.command()
- @commands.dm_only()
- async def adf(ctx, *, link=None):
- # channel where you want the ad to be posted
- # replace this id with ur channel id
- cid = 890196692304007188
- # Put your first or nick name here
- creator_name = "Narox"
- channel = client.get_channel(cid)
- if link == None:
- embed = discord.Embed(color=0xe02929)
- embed.add_field(name="AD - ERROR",
- value="Please insert your discord invite link", inline=False)
- embed.set_footer(text=f"Created by {creator_name}")
- await ctx.reply(embed=embed)
- elif link.startswith('https://discord.gg') == True or link.startswith('discord.gg/') == True:
- author = ctx.author.id
- try:
- # calculate cooldown time
- last_use = datetime.now() - on_cooldown[author]
- except KeyError:
- # the command is used for the first time , or bot was restarted
- last_use = None
- on_cooldown[author] = datetime.now()
- if last_use is None or last_use.seconds > use_cooldown:
- on_cooldown[author] = datetime.now()
- embed = discord.Embed(color=0x29e047)
- embed.add_field(
- name="Success", value=f"Successfully sent your FREE AD to <#{cid}>", inline=False)
- embed.set_footer(text=f"Created by {creator_name}")
- await ctx.reply(embed=embed)
- print(f"{ctx.author.name}#{ctx.author.discriminator} > Shared an AD!")
- embed2 = discord.Embed(color=0x29e047)
- embed2.add_field(
- name=f"AD By {ctx.author.name}#{ctx.author.discriminator}", value=f"{link}", inline=False)
- embed2.set_footer(text=f"Created by {creator_name}")
- await channel.send(embed=embed2)
- else:
- embed = discord.Embed(color=0xe02929)
- embed.add_field(
- name="AD - ERROR", value=f"You can only use this command once per hour , try again later!", inline=False)
- msg_sd = await ctx.reply(embed=embed)
- time.sleep(5)
- await msg_sd.delete()
- await ctx.message.delete()
- else:
- embed = discord.Embed(color=0xe02929)
- embed.add_field(name="AD - ERROR",
- value="Only discord links are allowed", inline=False)
- embed.set_footer(text=f"Created by {creator_name}")
- await ctx.reply(embed=embed)
- client.run(token)
- # https://www.youtube.com/c/NaroxEG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement