-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
181 lines (149 loc) · 6.65 KB
/
main.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import discord, io, aiohttp, time, asyncio, re, requests, praw
from discord.ext import tasks
from bs4 import BeautifulSoup
from discord.ext import commands
from typing import Awaitable
from urllib.request import urlopen
import urllib.request as urllib2
from datetime import datetime
from googlesearch import search
from youtube_search import YoutubeSearch
import random as _random
r = praw.Reddit(client_id=client_id.txt,
client_secret=client_secret.txt,
user_agent="my user agent")
TOKEN = token.txt
bot = commands.Bot(command_prefix='$')
client = discord.Client()
bot.remove_command('help')
@bot.command() # A google command cus why not
async def google(ctx, arg):
if arg == None:
await ctx.send("You need to add a search term! Ex) $google Carpe Diem")
else:
await ctx.send("https://www.google.com/search?q=" + arg)
query = arg
await ctx.send("**Top 5 results for **" + arg)
for results in search(query, stop=5):
await ctx.send("<"+results+">")
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for $help"))
@bot.command() # A youtube search because also why not
async def youtube(ctx, arg):
await ctx.send("https://www.youtube.com/results?search_query=" + arg)
@bot.command()
async def help(message):
embed = discord.Embed(colour=discord.Colour(0x4472e4), url="https://discordapp.com", description="**Google Search:**\n```CSS\n$google + [search term]```\n**Youtube Search:**\n```CSS\n$youtube + [search term]```\n**Memes:**\n```CSS\n$meme```\n**Spam a persons DM's:**\n```CSS\n$spam [@user] [message]```")
embed.set_author(name="StugotsZach ⚡", url="https://www.youtube.com/channel/UCZHIDwfPGxdbttd_Xwel9lw", icon_url="https://lh3.googleusercontent.com/a-/AOh14Ghq4OX1JHecJCDgTEwr5WbTkt9jKOtkZgOTPYw_Yw=s360-c")
embed.set_footer(text="⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆⛆")
await message.channel.send(content="**Help Message**", embed=embed)
@bot.command() #Displays a random meme from reddit; this took way longer to figure out than it should have :(
async def meme(ctx):
submission = r.subreddit("dankmemes").random()
await ctx.send(submission.url)
@bot.command()
async def reddit(ctx, arg):
try:
submission = r.subreddit(arg).random()
await ctx.send(submission.url)
except MissingRequiredArgument(param):
await ctx.send("Did you input a subreddit? or misspell?\nEx) ```$reddit dankmemes")
@bot.command()
async def blackmagic(ctx):
submission = r.subreddit("blackmagicfuckery").random()
await ctx.send(submission.url)
@bot.command(aliases=['ysk', 'YSK'])
async def youshouldknow(message):
submission = r.subreddit("YouShouldKnow").random()
text = submission.selftext
url = submission.url
today = datetime.today().strftime('%Y-%m-%d')
await message.channel.send("*Note if nothing happens the post is too long*")
embed = discord.Embed(title="Original Post", colour=discord.Colour(0xfffc5b), url=url, description="```" + text + "```")
embed.set_footer(text="Made by StugotsZach | " + today)
await message.channel.send(embed=embed)
@bot.command()
async def interesting(ctx):
submission = r.subreddit("Damnthatsinteresting").random()
try:
await ctx.send("**"+submission.title+"**")
await ctx.send(submission.selftext)
await ctx.send(submission.url)
except:
await ctx.send(submission.url)
await ctx.send(submission.title)
@bot.command()
async def showerthought(ctx):
submission1 = r.subreddit("Showerthoughts").random()
await ctx.send("```"+submission1.title+"```")
@bot.command()
async def profile(message, member: discord.Member):
userAvatarUrl = member.avatar_url
today = datetime.today().strftime('%Y-%m-%d')
embed = discord.Embed(title="**"+str(member)+"**", colour=discord.Colour(0xfffc5b))
embed.set_image(url=userAvatarUrl)
embed.set_footer(text="Made By StugotsZach | " + str(today))
await message.channel.send(embed=embed)
@bot.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def ban(ctx, member: discord.Member):
if administrator == False:
await ctx.send("Looks like you dont have the authority to ban anyone")
else:
await member.ban()
await member.send(member + "Its seems you have been banned from {ctx.guild.name}")
@bot.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
if administrator == False:
await ctx.send("Looks like you dont have the authority to ban anyone")
else:
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send("Unbanned @" + member)
@bot.command(aliases=['8ball', 'eightball'])
async def _8ball(ctx, *, question):
responses=['As I see it, yes',
'Ask again later',
'Better not tell you now',
'Cannot predict now',
'Concentrate and ask again',
'Don’t count on it',
'It is certain',
'It is decidedly so',
'Most likely',
'My reply is no',
'My sources say no',
'Outlook not so good',
'Outlook good',
'Reply hazy, try again',
'Signs point to yes',
'Very doubtful',
'Without a doubt',
'Yes',
'Yes – definitely',
'You may rely on it']
await ctx.send(_random.choice(responses))
@bot.command()
async def clear(ctx, amount=None):
try:
await ctx.channel.purge(limit=int(amount))
except TypeError:
await ctx.send("You need to have a number of messages to clear Ex) $clear 10")
@bot.command()
async def stats(ctx):
memberss = ctx.guild.member_count
guild_name = bot.get_guild("ID")
await ctx.send(guild_name + "\nTotal Members in guild: `" + str(memberss) + "`")
@bot.command()
async def servers():
servers = list(self.client.servers)
await ctx.send(f"Connected on {str(len(servers))} servers:")
await ctx.send('\n'.join(server.name for server in servers))
bot.run(TOKEN)