Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit a5e1883

Browse files
Add files via upload
1 parent 9012aa6 commit a5e1883

File tree

6 files changed

+349
-0
lines changed

6 files changed

+349
-0
lines changed
14.2 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python3 qwerty.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bad words goes here.
Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
#imports
2+
from ast import Return
3+
from importlib.resources import contents
4+
import discord
5+
import os
6+
from discord.ext import commands
7+
import random
8+
import numpy
9+
import time
10+
import re
11+
import string
12+
import asyncio
13+
import json
14+
import aiohttp
15+
16+
client = discord.Client()
17+
18+
#discord bot token
19+
TOKEN = 'X'
20+
21+
#Prefix
22+
bot = commands.Bot(command_prefix="#")
23+
24+
25+
#bot status in discord client and server ready message
26+
@bot.event
27+
async def on_ready():
28+
activity = discord.Game(name="#help", type=3)
29+
await bot.change_presence(status=discord.Status.idle, activity=activity)
30+
print("Bot is ready!")
31+
32+
#coinflip
33+
@bot.command(pass_context=True)
34+
async def coinflip(ctx):
35+
"""Flip a virtual coin!"""
36+
variable = [
37+
"```Heads!```",
38+
"```Tails!```",]
39+
await ctx.channel.send("{}".format(random.choice(variable)))
40+
41+
#dice
42+
@bot.command(pass_context=True)
43+
async def dice(ctx):
44+
"""Throws a virtual 6 sided die."""
45+
variable = [
46+
"```1```",
47+
"```2```",
48+
"```3```",
49+
"```4```",
50+
"```5```",
51+
"```6```",
52+
]
53+
await ctx.channel.send("{}".format(random.choice(variable)))
54+
55+
#ping
56+
@bot.command()
57+
async def ping(ctx):
58+
"""Check the bot ping!"""
59+
await ctx.send(f"{client.latency}")
60+
if round(client.latency * 1000) <= 50:
61+
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0x44ff44)
62+
elif round(client.latency * 1000) <= 100:
63+
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0xffd000)
64+
elif round(client.latency * 1000) <= 200:
65+
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0xff6600)
66+
else:
67+
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0x990000)
68+
await ctx.send(embed=embed)
69+
70+
71+
#weclome message dm
72+
@client.event
73+
async def on_member_join(member, ctx):
74+
await ctx.author.send("```Hello there!```")
75+
76+
77+
#membercount
78+
@bot.command()
79+
async def membercount(ctx):
80+
"""Check the server membercount!"""
81+
embed = discord.Embed(
82+
title=('Membercount'),
83+
description =(f'There are currently **{ctx.guild.member_count}** members in the server!'),
84+
85+
color= discord.Colour.dark_blue()
86+
)
87+
embed.set_footer(text='QWERTY')
88+
embed.set_thumbnail(url='')
89+
await ctx.send(embed=embed)
90+
91+
92+
#bot-commands
93+
@bot.command(aliases=['about'])
94+
async def info(ctx):
95+
"""About the bot!"""
96+
embed = discord.Embed(
97+
title=('Info'),
98+
description =(f'A Discord bot made by QwertyIsThinking#1587 for moderation and for fun! It is self hosted and is made with Discord.py!'),
99+
100+
color= discord.Colour.dark_blue()
101+
)
102+
embed.set_footer(text='QWERTY')
103+
embed.set_thumbnail(url='')
104+
await ctx.send(embed=embed)
105+
106+
107+
#bot invite
108+
@bot.command(pass_context=True)
109+
async def invite(ctx):
110+
"""Invite this bot to your server!"""
111+
112+
embed = discord.Embed(
113+
title=('Invite'),
114+
description =(f'Here is the invitation link: https://discord.com/api/oauth2/authorize?client_id=927841410319781908&permissions=449160039488&scope=bot'),
115+
116+
color= discord.Colour.dark_blue()
117+
)
118+
embed.set_footer(text='QWERTY')
119+
embed.set_thumbnail(url='')
120+
await ctx.send(embed=embed)
121+
122+
#test the bot to see if it is online
123+
@bot.command(aliases=['test'])
124+
async def status(ctx):
125+
"""Is the bot okay?"""
126+
embed = discord.Embed(
127+
title=('Status'),
128+
description =(f'The bot is online and everything SEEMS to be fine!'),
129+
130+
color= discord.Colour.dark_blue()
131+
)
132+
embed.set_footer(text='QWERTY')
133+
embed.set_thumbnail(url='')
134+
await ctx.send(embed=embed)
135+
136+
#your discord server invite, in this case, it is my discord server invite
137+
@bot.command(pass_context=True)
138+
async def server(ctx):
139+
"""The creator's main server!"""
140+
await ctx.channel.send('Here is the server invite for main server: https://discord.gg/JE2AfPm2Yu')
141+
142+
#the discord bot support server, you can make your own support server if you are the one hosting it
143+
@bot.command(pass_context=True)
144+
async def support(ctx):
145+
"""Support server!"""
146+
await ctx.channel.send('Here is the support server link: https://discord.gg/7RSxKSaN68')
147+
@bot.command(pass_context = True)
148+
149+
#owner
150+
@commands.is_owner()
151+
async def owner(ctx):
152+
"""Shows if you are the true owner of the bot or not."""
153+
await ctx.channel.send('```If you executed this command, then you are the owner of this bot!```')
154+
155+
#badwords filter
156+
with open('badwords.txt') as file:
157+
file = file.read().split()
158+
159+
@bot.event
160+
async def on_message(message):
161+
mybot = bot.get_user('X')
162+
163+
if message.author is mybot:
164+
return
165+
166+
flag = False
167+
for badword in file:
168+
if badword in message.content.lower():
169+
await message.delete()
170+
await message.channel.send(f'{message.author.mention}! Foul language.')
171+
flag = True
172+
173+
if not flag:
174+
await bot.process_commands(message)
175+
176+
#repeat
177+
@bot.command()
178+
async def repeat(ctx, *, message):
179+
"""Repeats what you type in."""
180+
181+
await ctx.channel.send(message)
182+
183+
#dms
184+
@bot.command(pass_context = True)
185+
@commands.is_owner()
186+
async def setprefix(ctx, prefix):
187+
188+
bot.command_prefix = prefix
189+
await ctx.send(f"Prefix changed to ``{prefix}``")
190+
await ctx.author.send("Alert! Prefix changed to ``{prefix}``!")
191+
192+
#timer
193+
@bot.command()
194+
async def timer(ctx, time: int):
195+
"""Timer(seconds) after the prefix(no.)-May be laggy."""
196+
await ctx.send("Timer started")
197+
def check(message):
198+
return message.channel == ctx.channel and message.author == ctx.author and message.content.lower() == "cancel"
199+
try:
200+
m = await bot.wait_for("message", check=check, timeout=time)
201+
await ctx.send("Timer cancelled")
202+
except asyncio.TimeoutError:
203+
await ctx.channel.send('Timer is ringing {}!'.format(ctx.author.mention))
204+
205+
#nicknames
206+
@bot.command()
207+
@commands.has_permissions(administrator = True)
208+
async def nickname(ctx, m: discord.Member, *, newnick):
209+
"""A nickname command for admins!"""
210+
await m.edit(nick=newnick)
211+
await ctx.send('Nickname changed.')
212+
213+
#licence
214+
@bot.command(aliases=['terms'])
215+
async def licence(ctx):
216+
"""Licence!"""
217+
embed = discord.Embed(
218+
title=('Info'),
219+
description =(f'This bot is distributed under the GPL 3.0 licence. Read the terms and conditions before using the code.'),
220+
221+
color= discord.Colour.dark_blue()
222+
)
223+
embed.set_footer(text='QWERTY')
224+
embed.set_thumbnail(url='')
225+
await ctx.send(embed=embed)
226+
227+
#github
228+
@bot.command(aliases=['source'])
229+
async def github(ctx):
230+
"""The GitHub page!"""
231+
await ctx.channel.send('https://github.com/QwertyIsCoding/QwertyBot')
232+
233+
# When a member joins, the bot DM's them a message
234+
@client.event
235+
async def on_member_join(member):
236+
await client.send_message(member, 'Welcome to the server {}, Enjoy your stay! Also, Check out the rules and feel free to take prt in server events!'.format(member.name))
237+
238+
239+
240+
@bot.command(help = "Prints details of Server")
241+
async def details(ctx):
242+
owner=str(ctx.guild.owner)
243+
region = str(ctx.guild.region)
244+
guild_id = str(ctx.guild.id)
245+
memberCount = str(ctx.guild.member_count)
246+
icon = str(ctx.guild.icon_url)
247+
desc=ctx.guild.description
248+
249+
embed = discord.Embed(
250+
title=ctx.guild.name + " Server Information",
251+
description=desc,
252+
color=discord.Color.blue()
253+
)
254+
embed.set_thumbnail(url=icon)
255+
embed.add_field(name="Owner", value=owner, inline=True)
256+
embed.add_field(name="Server ID", value=guild_id, inline=True)
257+
embed.add_field(name="Region", value=region, inline=True)
258+
embed.add_field(name="Member Count", value=memberCount, inline=True)
259+
260+
await ctx.send(embed=embed)
261+
262+
members=[]
263+
async for member in ctx.guild.fetch_members(limit=150) :
264+
await ctx.send('Name : {}\t Status : {}\n Joined at {}'.format(member.display_name,str(member.status),str(member.joined_at)))
265+
266+
267+
268+
#this is buggy
269+
@bot.event
270+
async def on_member_join(member):
271+
for channel in member.guild.text_channels :
272+
if str(channel) == "general" :
273+
on_mobile=False
274+
if member.is_on_mobile() == True :
275+
on_mobile = True
276+
await channel.send("Welcome to the Server {}!!\n On Mobile : {}".format(member.name,on_mobile))
277+
278+
279+
#make a command to check user's roles
280+
#this is not working yet
281+
@bot.command()
282+
async def roles(ctx, member: discord.Member):
283+
"""Check user's roles!"""
284+
roles = [role for role in member.roles]
285+
embed = discord.Embed(
286+
title=f"{member}'s roles",
287+
description="\n".join(roles),
288+
color=discord.Color.blue()
289+
)
290+
await ctx.send(embed=embed)
291+
292+
#make a command for a calculator in discord and round off the answer
293+
@bot.command()
294+
async def calc(ctx, *, equation):
295+
"""Calculate anything!"""
296+
try:
297+
answer = eval(equation)
298+
except Exception:
299+
await ctx.send("Invalid equation!")
300+
return
301+
embed = discord.Embed(
302+
title="Calculator",
303+
description=f"{equation} = {answer}",
304+
color=discord.Color.blue()
305+
)
306+
await ctx.send(embed=embed)
307+
308+
309+
#make a command to search for gifs
310+
@client.command(pass_context=True)
311+
async def giphy(ctx, *, search):
312+
embed = discord.Embed(colour=discord.Colour.blue())
313+
session = aiohttp.ClientSession()
314+
315+
if search == '':
316+
response = await session.get('https://api.giphy.com/v1/gifs/random?api_key=API_KEY_GOES_HERE')
317+
data = json.loads(await response.text())
318+
embed.set_image(url=data['data']['images']['original']['url'])
319+
else:
320+
search.replace(' ', '+')
321+
response = await session.get('http://api.giphy.com/v1/gifs/search?q=' + search + '&api_key=API_KEY_GOES_HERE&limit=10')
322+
data = json.loads(await response.text())
323+
gif_choice = random.randint(0, 9)
324+
embed.set_image(url=data['data'][gif_choice]['images']['original']['url'])
325+
326+
await session.close()
327+
328+
await client.send_message(embed=embed)
329+
330+
#number guessing game
331+
@commands.command()
332+
async def guess(self, ctx):
333+
number = random.randint(0, 100)
334+
for i in range(0, 5):
335+
await ctx.send('guess')
336+
response = await self.bot.wait_for('message')
337+
guess = int(response.content)
338+
if guess > number:
339+
await ctx.send('bigger')
340+
elif guess < number:
341+
await ctx.send('smaller')
342+
else:
343+
await ctx.send('true')
344+
345+
bot.run(TOKEN)
346+
client.run(TOKEN)
1018 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.9.10

0 commit comments

Comments
 (0)