-
Notifications
You must be signed in to change notification settings - Fork 2
/
file.py
75 lines (71 loc) · 4.27 KB
/
file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import discord
from discord.ext import commands
from discord import Webhook,AsyncWebhookAdapter
import re
from discord.ext.commands import MissingRequiredArgument
from discord.ext.commands import CommandInvokeError
from discord.ext.commands import MissingPermissions
from discord.ext.commands import has_permissions
from discord import Embed
import json
import aiohttp
from datetime import datetime
intents = discord.Intents(messages=True,guilds=True)
client = commands.Bot(command_prefix = "!",case_insensitive=True,intents=intents)
def global_dm_check(author, guild):
def inner_check(message):
return message.author == author and message.guild == None
return inner_check
@client.command(help = "Starts the advertising prompt in your DMs")
@commands.cooldown(1, 14400, commands.BucketType.user)
async def advertise(ctx):
try:
author = ctx.message.author
channel = client.get_channel(783714673425776701)
checkdms = Embed(title = "Please check your DMs!",color=discord.Color.green())
msgyes = await ctx.send(embed = checkdms)
q1 = discord.Embed(title = "Company name?")
msgyes = await author.send(embed = q1)
waitmsg1 = await client.wait_for('message',check=global_dm_check(ctx.author,ctx.guild))
name = waitmsg1.content
q2 = discord.Embed(title = "Motto?",description = "Keep it nice and short. Ex. \"We sell quality products at quality prices\" instead of \"We are the best tech group on Roblox selling over twenty products with minimal prices.\"")
msgyes = await author.send(embed = q2)
waitmsg1 = await client.wait_for('message',check=global_dm_check(ctx.author,ctx.guild))
motto = waitmsg1.content
q3 = discord.Embed(title = "Invite or website?",description = "Choose **one**.\nNo Bit.ly/shortened links allowed please.")
msgyes = await author.send(embed = q3)
waitmsg1 = await client.wait_for('message',check=global_dm_check(ctx.author,ctx.guild))
invite = waitmsg1.content
q4 = discord.Embed(title = "Image LINK?",description = "Please send one **image link** for a product you've made. ***Don't send a file,*** send a Gyazo/Flyro link.")
q4.set_footer(text = "Say skip to skip.")
msgyes = await author.send(embed = q4)
waitmsg1 = await client.wait_for('message',check=global_dm_check(ctx.author,ctx.guild))
image = waitmsg1.content
if image == "Skip" or image == "skip":
image = None
try:
buildembed = discord.Embed(title = f"{name} **|| AD**",description=motto,timestamp=datetime.utcnow())
buildembed.add_field(name = "Link:",value = invite)
if image != None:
buildembed.set_image(url = image)
buildembed.set_footer(icon_url = ctx.author.avatar_url,text = f"Sent by {ctx.author}")
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('Webhook URL here', adapter=AsyncWebhookAdapter(session))
await webhook.send(embed=buildembed, username=ctx.author.name,avatar_url=ctx.author.avatar_url)
done = Embed(title = "All sent!",description = "Thanks for your patience throughout this process.",color=discord.Color.green())
msgyes = await author.send(embed = done)
except discord.Forbidden:
error = Embed(title = "You sent a file, not an image URL.",description = "Please get a CDN link to a featured image. You're going to have to wait four hours before you try again.",color = discord.Color.red())
msgyes = await author.send(embed = error)
except discord.Forbidden:
error = Embed(title = "I can't DM you!",color=discord.Color.red())
msgyes = await ctx.send(Embed = error)
@advertise.error
async def advertise_error(ctx,error):
if isinstance(error,commands.CommandOnCooldown):
cooldown = Embed(title = "Slow down there friend",description = "Pilot, slow down there. You're still on cooldown! Please only use this command once every 4 hours.",color=discord.Color.orange())
cooldown.set_thumbnail(url = "https://media.giphy.com/media/dJezVlwfVulTykjRQj/giphy.gif")
msgyes = await ctx.send(embed = cooldown)
else:
print(f"Something went wrong there, here's an error: {error}")
client.run("Token here")