-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (72 loc) · 4.37 KB
/
main.py
File metadata and controls
101 lines (72 loc) · 4.37 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import discord
from discord.ext import commands
import requests
token = YOUR_BOT_PREFIX_HERE
prefix = YOUR_BOT_TOKEN_HERE
client = commands.Bot(command_prefix= prefix)
client.remove_command("help") #to remove the default boring help command
@client.event
async def on_ready():
print("We have logged in as {0.user} ".format(client))
activity = discord.Game(name=".help", type=3) # this is to writing prefix in playing a game.(optional)
await client.change_presence(status=discord.Status.online, activity=activity) # this is for making the status as an online and writing prefix in playing a game.(optional)
#Help commands
@client.group(invoke_without_command=True)
async def help(ctx):
embed = discord.Embed(title="IndianDesiMemer Help Center ✨",color=0xF49726)
embed.add_field(name="Command Categories :",value="🐸 `memes :` Image generation with a memey twist.\n" + "🔧 `utility :` Bot utility zone\n😏 `nsfw :` Image generation with a memey twist.\n\nTo view the commands of a category, send `.help <category>`" ,inline=False)
embed.set_footer(icon_url=ctx.author.avatar_url,text="Help requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed)
#Sub-help command of memes
@help.command ()
async def memes(ctx):
embed=discord.Embed(title="IndianDesiMemer Help Center ✨", description="Commands of **meme** \n`.meme:`Memes",inline=False)
embed.set_footer(icon_url=ctx.author.avatar_url,text="Command requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed)
#Sub-help commands of nsfw
@help.command ()
async def nsfw(ctx) :
embed=discord.Embed(title="IndianDesiMemer Help Center ✨", description="Commands of **nsfw** \n`.nsfw:`NSFW", color=0xF49726)
embed.set_footer(icon_url=ctx.author.avatar_url,text="Command requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed)
#Sub-help commands of utility
@help.command ()
async def utility(ctx) :
embed=discord.Embed(title="IndianDesiMemer Help Center ✨", description="Commands of **utility** \n`.ping:`Latency", color=0xF49726)
embed.set_footer(icon_url=ctx.author.avatar_url,text="Command requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed)
# it is used for the cooldown to prevent the bot from spam attack
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send("**Try after {0} second ".format(round(error.retry_after, 2)))
#meme command
@client.command()
@commands.cooldown(1, 10, commands.BucketType.channel) # it is used for the cooldown to prevent the bot from spam attack
async def meme(ctx):
response = requests.get("https://meme-api.herokuapp.com/gimme/"+"memes"+"memes"+"?t=all?hot")
m = response.json()
postLink = (m["postLink"])
subreddit = (m["subreddit"])
title = (m["title"])
imageUrl = (m["url"])
upVote = (m["ups"])
uv = str(upVote)
embed=discord.Embed(title= title, url=postLink,color=0xF49726)
embed.set_image(url=imageUrl)
embed.set_footer(text="\n👍\t"+ uv+ " By :r/"+subreddit)
await ctx.send(embed=embed)
#nsfw command
@client.command()
@commands.cooldown(1, 10, commands.BucketType.channel)
async def nsfw(ctx):
if ctx.channel.is_nsfw():
print("nsfw work!!")
else:
print("You can use this command in a nsfw channel only !")
#ping command
@client.command()
@commands.cooldown(1, 10, commands.BucketType.channel) # it is used for the cooldown to prevent the bot from spam attack
async def ping(ctx):
await ctx.send('Ping! **{0}**ms'.format(round(client.latency, 1)))
client.run(token)