everything push
This commit is contained in:
parent
21c4d3529c
commit
bb8b19a5b6
126
scr/Modules/Hub/Database/addServer OLD.txt
Normal file
126
scr/Modules/Hub/Database/addServer OLD.txt
Normal file
@ -0,0 +1,126 @@
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
import pymysql
|
||||
import asyncio
|
||||
|
||||
con = pymysql.connect(host='192.168.1.52',
|
||||
user='Quentin',
|
||||
password='kaPl0wskii',
|
||||
db='serverIDs',
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
|
||||
|
||||
class AddServer(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, ctx):
|
||||
if isinstance(ctx.channel, discord.DMChannel):
|
||||
if ctx.content.lower() == "add server":
|
||||
await ctx.channel.send("Send me an invite to the server. Say ``cancel`` anytime to cancel.")
|
||||
try:
|
||||
invite = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel, timeout=20)
|
||||
if invite.content == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
else:
|
||||
is_invite = invite.content.find("discord.gg")
|
||||
try:
|
||||
if is_invite > 0:
|
||||
invite = await self.client.fetch_invite(invite.content, with_counts=True)
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
server_exists = cur.execute(f"SELECT ID FROM servers WHERE ID = {invite.guild.id}")
|
||||
|
||||
if server_exists == 0:
|
||||
try:
|
||||
if invite.guild.owner == ctx.author:
|
||||
if invite.max_uses is None:
|
||||
await ctx.channel.send("Please send a description of the server")
|
||||
description = await self.client.wait_for("message", check=lambda message:
|
||||
message.author == ctx.author and
|
||||
message.channel == ctx.channel,
|
||||
timeout=60)
|
||||
if description.content == "cancel":
|
||||
await ctx.channel.send("Process canceled. If need be have "
|
||||
"this pre typed")
|
||||
else:
|
||||
await ctx.channel.send("Please send a list of tags separated by a "
|
||||
"comma(,) no spaces")
|
||||
tags = await self.client.wait_for("message", check=lambda message:
|
||||
message.author == ctx.author
|
||||
and message.channel == ctx.channel)
|
||||
if tags == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
else:
|
||||
try:
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f"INSERT INTO servers "
|
||||
f"(ID, name, category, tags, description, raiting, nsfw, invite, sent) "
|
||||
f"VALUES ({invite.guild.id},'"
|
||||
f"{invite.guild.name}','"
|
||||
f"{}"
|
||||
f"{tags.content}','"
|
||||
f"{invite.code}','"
|
||||
f"{description.content}')")
|
||||
await ctx.channel.send("Server added successfully")
|
||||
|
||||
embed = discord.Embed(
|
||||
colour=discord.Colour.green()
|
||||
)
|
||||
embed.set_author(name="Server Added")
|
||||
embed.add_field(name="ID", value=f"{invite.guild.id}", inline=False)
|
||||
embed.add_field(name="Name", value=f"{invite.guild.name}", inline=False)
|
||||
embed.add_field(name="Tags", value=f"{tags.content}", inline=False)
|
||||
embed.add_field(name="Code", value=f"{invite.code}", inline=False)
|
||||
embed.add_field(name="Description", value=f"{description.content}", inline=False)
|
||||
await self.client.get_channel(658442038475358238).send(embed=embed)
|
||||
|
||||
except Exception as e:
|
||||
await ctx.channel.send("An error has occurred and will be fixed"
|
||||
"shortly.")
|
||||
print(e)
|
||||
await self.client.get_channel(656997125627969546).send(e)
|
||||
await self.client.\
|
||||
get_channel(656997125627969546).\
|
||||
send("<@305589587215122432>")
|
||||
else:
|
||||
await ctx.channel.send("Cannot verify server ownership. "
|
||||
"Either you are not the guild owner or "
|
||||
"the bot has not been added to verify ownership.\n"
|
||||
"Add the bot here : https://discordapp.com/api/oauth2"
|
||||
"/authorize?client_"
|
||||
"id=501485906801459200&permissions=1024"
|
||||
"&scope=bot\n"
|
||||
"Once the bot is added restart the verification process "
|
||||
"using ``add server`` in this DM\n"
|
||||
"After ownership is verified the bot can be removed.")
|
||||
|
||||
except AttributeError:
|
||||
await ctx.channel.send("Cannot verify server ownership. "
|
||||
"Either you are not the guild owner or "
|
||||
"the bot has not been added to verify ownership.\n"
|
||||
"Add the bot here : https://discordapp.com/api/oauth2"
|
||||
"/authorize?client_id=501485906801459200&permissions=1024"
|
||||
"&scope=bot\n"
|
||||
"Once the bot is added restart the verification process "
|
||||
"using ``add server`` in this DM\n"
|
||||
"After ownership is verified the bot can be removed.")
|
||||
|
||||
else:
|
||||
await ctx.channel.send("It seems this server is already in our databases. "
|
||||
"It can be removed with ``remove server``")
|
||||
|
||||
else:
|
||||
await ctx.channel.send("Invalid invite.")
|
||||
except discord.errors.NotFound:
|
||||
await ctx.channel.send("Invalid invite.")
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.channel.send("Process timeout.")
|
||||
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(AddServer(client))
|
@ -17,107 +17,100 @@ class AddServer(commands.Cog):
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, ctx):
|
||||
if isinstance(ctx.channel, discord.DMChannel):
|
||||
if ctx.content.lower() == "add server":
|
||||
if isinstance(ctx.channel, discord.DMChannel) and (ctx.content.lower() == "add server"):
|
||||
try:
|
||||
await ctx.channel.send("Send me an invite to the server. Say ``cancel`` anytime to cancel.")
|
||||
try:
|
||||
invite = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel, timeout=20)
|
||||
if invite.content == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
invite = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel,
|
||||
timeout=20)
|
||||
invite = await self.client.fetch_invite(invite.content)
|
||||
if invite == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
return
|
||||
|
||||
categorys = self.client.get_channel(656998225076551680)
|
||||
print(categorys.channels)
|
||||
category_names = ""
|
||||
for channel in categorys.channels:
|
||||
category_names = category_names + '`' + channel.name + '` | '
|
||||
await ctx.channel.send("Please slect a category from the following. This will change how the server"
|
||||
"is shown in the Hub server \n" + category_names)
|
||||
category = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel, timeout=20)
|
||||
category = category.content.lower
|
||||
if category == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
return
|
||||
for channel in categorys.channels:
|
||||
if category == channel.name:
|
||||
pass
|
||||
else:
|
||||
is_invite = invite.content.find("discord.gg")
|
||||
try:
|
||||
if is_invite > 0:
|
||||
invite = await self.client.fetch_invite(invite.content, with_counts=True)
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
server_exists = cur.execute(f"SELECT ID FROM servers WHERE ID = {invite.guild.id}")
|
||||
category = "other"
|
||||
|
||||
if server_exists == 0:
|
||||
try:
|
||||
if invite.guild.owner == ctx.author:
|
||||
if invite.max_uses is None:
|
||||
await ctx.channel.send("Please send a description of the server")
|
||||
description = await self.client.wait_for("message", check=lambda message:
|
||||
message.author == ctx.author and
|
||||
message.channel == ctx.channel,
|
||||
timeout=60)
|
||||
if description.content == "cancel":
|
||||
await ctx.channel.send("Process canceled. If need be have "
|
||||
"this pre typed")
|
||||
else:
|
||||
await ctx.channel.send("Please send a list of tags separated by a "
|
||||
"comma(,) no spaces")
|
||||
tags = await self.client.wait_for("message", check=lambda message:
|
||||
message.author == ctx.author
|
||||
and message.channel == ctx.channel)
|
||||
if tags == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
else:
|
||||
try:
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f"INSERT INTO servers "
|
||||
f"(ID, name, tags, invite, description) "
|
||||
f"VALUES ({invite.guild.id},'"
|
||||
f"{invite.guild.name}','"
|
||||
f"{tags.content}','{invite.code}','"
|
||||
f"{description.content}')")
|
||||
await ctx.channel.send("Server added successfully")
|
||||
await ctx.channel.send("Please send a list of tags separated by a "
|
||||
"comma(,) no spaces")
|
||||
tags = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel,
|
||||
timeout=20)
|
||||
if tags == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
return
|
||||
|
||||
embed = discord.Embed(
|
||||
colour=discord.Colour.green()
|
||||
)
|
||||
embed.set_author(name="Server Added")
|
||||
embed.add_field(name="ID", value=f"{invite.guild.id}", inline=False)
|
||||
embed.add_field(name="Name", value=f"{invite.guild.name}", inline=False)
|
||||
embed.add_field(name="Tags", value=f"{tags.content}", inline=False)
|
||||
embed.add_field(name="Code", value=f"{invite.code}", inline=False)
|
||||
embed.add_field(name="Description", value=f"{description.content}", inline=False)
|
||||
await self.client.get_channel(658442038475358238).send(embed=embed)
|
||||
await ctx.channel.send("Please send a description of the server")
|
||||
description = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel,
|
||||
timeout=20)
|
||||
if description == "cancel":
|
||||
await ctx.channel.send("Process canceled")
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
await ctx.channel.send("An error has occurred and will be fixed"
|
||||
"shortly.")
|
||||
print(e)
|
||||
await self.client.get_channel(656997125627969546).send(e)
|
||||
await self.client.\
|
||||
get_channel(656997125627969546).\
|
||||
send("<@305589587215122432>")
|
||||
else:
|
||||
await ctx.channel.send("Cannot verify server ownership. "
|
||||
"Either you are not the guild owner or "
|
||||
"the bot has not been added to verify ownership.\n"
|
||||
"Add the bot here : https://discordapp.com/api/oauth2"
|
||||
"/authorize?client_"
|
||||
"id=501485906801459200&permissions=1024"
|
||||
"&scope=bot\n"
|
||||
"Once the bot is added restart the verification process "
|
||||
"using ``add server`` in this DM\n"
|
||||
"After ownership is verified the bot can be removed.")
|
||||
nsfw = 0
|
||||
for channel in invite.guild.channels:
|
||||
try:
|
||||
if channel.is_nsfw():
|
||||
nsfw = 1
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
except AttributeError:
|
||||
await ctx.channel.send("Cannot verify server ownership. "
|
||||
"Either you are not the guild owner or "
|
||||
"the bot has not been added to verify ownership.\n"
|
||||
"Add the bot here : https://discordapp.com/api/oauth2"
|
||||
"/authorize?client_id=501485906801459200&permissions=1024"
|
||||
"&scope=bot\n"
|
||||
"Once the bot is added restart the verification process "
|
||||
"using ``add server`` in this DM\n"
|
||||
"After ownership is verified the bot can be removed.")
|
||||
|
||||
else:
|
||||
await ctx.channel.send("It seems this server is already in our databases. "
|
||||
"It can be removed with ``remove server``")
|
||||
try:
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f"INSERT INTO servers "
|
||||
f"(ID, name, category, tags, description, nsfw, invite, submitter) "
|
||||
f"VALUES ({invite.guild.id},'"
|
||||
f"{invite.guild.name}','"
|
||||
f"{category}','"
|
||||
f"{tags.content}','"
|
||||
f"{description.content}','"
|
||||
f"{nsfw}','"
|
||||
f"{invite.code}','"
|
||||
f"{ctx.author.id}')")
|
||||
await ctx.channel.send("Server added successfully")
|
||||
|
||||
else:
|
||||
await ctx.channel.send("Invalid invite.")
|
||||
except discord.errors.NotFound:
|
||||
await ctx.channel.send("Invalid invite.")
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.channel.send("Process timeout.")
|
||||
embed = discord.Embed(
|
||||
colour=discord.Colour.green()
|
||||
)
|
||||
embed.set_author(name="Server Added")
|
||||
embed.add_field(name="ID", value=f"{invite.guild.id}", inline=False)
|
||||
embed.add_field(name="Name", value=f"{invite.guild.name}", inline=False)
|
||||
embed.add_field(name="Tags", value=f"{tags.content}", inline=False)
|
||||
embed.add_field(name="Code", value=f"{invite.code}", inline=False)
|
||||
embed.add_field(name="Description", value=f"{description.content}", inline=False)
|
||||
await self.client.get_channel(658442038475358238).send(embed=embed)
|
||||
|
||||
except Exception as e:
|
||||
await ctx.channel.send("An error has occurred and will be fixed"
|
||||
"shortly.")
|
||||
print(e)
|
||||
await self.client.get_channel(656997125627969546).send(e)
|
||||
await self.client. \
|
||||
get_channel(656997125627969546). \
|
||||
send("<@305589587215122432>")
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
await ctx.channel.send("Process timeout")
|
||||
return
|
||||
|
||||
|
||||
def setup(client):
|
||||
|
@ -0,0 +1,56 @@
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
import pymysql
|
||||
|
||||
con = pymysql.connect(host='192.168.1.52',
|
||||
user='Quentin',
|
||||
password='kaPl0wskii',
|
||||
db='serverIDs',
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
|
||||
|
||||
class RemoveServer(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, ctx):
|
||||
if isinstance(ctx.channel, discord.DMChannel):
|
||||
if ctx.content.lower() == "remove server":
|
||||
await ctx.channel.send("Send the server ID.")
|
||||
server_id = await self.client.wait_for("message", check=lambda message: message.author == ctx.author)
|
||||
try:
|
||||
server_id = int(server_id.content)
|
||||
except ValueError:
|
||||
await ctx.channel.send("Invalid server ID")
|
||||
|
||||
try:
|
||||
member = self.client.get_guild(server_id).get_member(ctx.author.id)
|
||||
if member.guild_permissions.manage_guild:
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
server_exists = cur.execute(f"SELECT ID FROM servers WHERE ID = {server_id}")
|
||||
if server_exists == 0:
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f"DELETE FROM servers WHERE ID={server_id}")
|
||||
else:
|
||||
await ctx.channel.send("That server could not be found in our databases")
|
||||
|
||||
except AttributeError:
|
||||
await ctx.channel.send("Cannot verify server ownership. "
|
||||
"Either you are not the guild owner or "
|
||||
"the bot has not been added to verify ownership.\n"
|
||||
"Add the bot here : https://discordapp.com/api/oauth2"
|
||||
"/authorize?client_id=501485906801459200&permissions=1024"
|
||||
"&scope=bot\n"
|
||||
"Once the bot is added restart the verification process "
|
||||
"using ``remove server`` in this DM\n"
|
||||
"After ownership is verified the bot can be removed.")
|
||||
|
||||
|
||||
# todo
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(RemoveServer(client))
|
38
scr/Modules/Temp.py
Normal file
38
scr/Modules/Temp.py
Normal file
@ -0,0 +1,38 @@
|
||||
from discord.ext import commands
|
||||
import discord
|
||||
import pymysql
|
||||
import asyncio
|
||||
|
||||
con = pymysql.connect(host='192.168.1.52',
|
||||
user='Quentin',
|
||||
password='kaPl0wskii',
|
||||
db='Temp',
|
||||
charset='utf8mb4',
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
|
||||
|
||||
class Temp(commands.Cog):
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, ctx):
|
||||
if isinstance(ctx.channel, discord.DMChannel) and (ctx.content.lower() == "temp"):
|
||||
await ctx.channel.send("Send me the data")
|
||||
data = await self.client.wait_for("message", check=lambda message: message.author == ctx.author
|
||||
and message.channel == ctx.channel,
|
||||
timeout=50)
|
||||
user = await self.client.fetch_user(int(data.content))
|
||||
list = [0, '', '']
|
||||
list[0] = int(data.content)
|
||||
list[1] = user.name
|
||||
list[2] = user.created_at
|
||||
print(list)
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cur.execute(f"INSERT INTO Temp.temp (userID, name, joinDate) VALUES ('{list[0]}','{list[1]}','{list[2]}')")
|
||||
await ctx.channel.send(f"User added successfully: {list[0]}, {list[1]}, {list[2]}")
|
||||
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(Temp(client))
|
@ -2,7 +2,7 @@ from discord.ext.commands import Bot
|
||||
|
||||
cogs = ["Modules.TGH.automod.automod", "Modules.TGH.automod.ouat",
|
||||
"Modules.SSC.autoReply.Join", "Modules.SSC.autoReply.Leave",
|
||||
"Modules.Hub.Database.addServer"]
|
||||
"Modules.Temp"]
|
||||
|
||||
prefix = 'o!'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user