|
| 1 | +<<<<<<< HEAD |
| 2 | +import os |
| 3 | +import discord |
| 4 | +import pyodbc |
| 5 | +import time |
| 6 | +import datetime |
| 7 | +import subprocess |
| 8 | + |
| 9 | +from dotenv import load_dotenv |
| 10 | +from discord.ext import commands |
| 11 | + |
| 12 | +load_dotenv() |
| 13 | + |
| 14 | +conncreate = pyodbc.connect('driver={%s};server=%s;database=%s;uid=%s;pwd=%s' % |
| 15 | +( os.getenv('DRIVER'), os.getenv('SERVER'), os.getenv('DATABASE'), os.getenv('UID'), os.getenv('PASS') ) ) |
| 16 | + |
| 17 | +now = datetime.datetime.now().strftime("%d.%b %Y %H:%M:%S") |
| 18 | + |
| 19 | +client = discord.Client() |
| 20 | +bot = commands.Bot(command_prefix='!') |
| 21 | + |
| 22 | + |
| 23 | +@bot.event |
| 24 | +async def on_ready(): |
| 25 | + print('[%s] ----- BOT ONLINE -----' % (now)) |
| 26 | + |
| 27 | +@bot.command(name='createinv') |
| 28 | +async def createinv(ctx): |
| 29 | + #creating invite link |
| 30 | + invitelink = await ctx.channel.create_invite(max_uses=1,unique=True) |
| 31 | + sender = ctx.message.author |
| 32 | + #removing the url |
| 33 | + discordlink = invitelink.url |
| 34 | + invlink = discordlink.replace("https://discord.gg/","") |
| 35 | + #storing in db |
| 36 | + cursor = conncreate |
| 37 | + cursor.execute("INSERT INTO dbo.discordinv (invlink) VALUES (?)", invlink) |
| 38 | + cursor.commit() |
| 39 | + sender = ctx.message.author |
| 40 | + print('[%s][%s] has created an invite link: %s' % (now,sender,invitelink.url)) |
| 41 | + await ctx.send(invitelink) |
| 42 | + |
| 43 | +@bot.command(name='startserver') |
| 44 | +@commands.has_role('MR GM') |
| 45 | +async def startserver(ctx): |
| 46 | + os.system(os.getenv('SERVER_PATH') + "Start_Server.bat") |
| 47 | + print('[%s][%s] has started the Server' % (now,ctx.message.author)) |
| 48 | + await ctx.send('[%s] has started the Server' % (ctx.message.author)) |
| 49 | + |
| 50 | +@bot.command(name='stopserver') |
| 51 | +@commands.has_role('MR GM') |
| 52 | +async def stopserver(ctx): |
| 53 | + os.system(os.getenv('SERVER_PATH') + "Stop_Server.bat") |
| 54 | + print('[%s][%s] has started the Server' % (now,ctx.message.author)) |
| 55 | + await ctx.send('[%s] has started the Server' % (ctx.message.author)) |
| 56 | + |
| 57 | +bot.run(os.getenv('TOKEN')) |
| 58 | +======= |
| 59 | +import os |
| 60 | +import discord |
| 61 | +import pyodbc |
| 62 | +import time |
| 63 | +import datetime |
| 64 | + |
| 65 | +from dotenv import load_dotenv |
| 66 | +from discord.ext import commands |
| 67 | + |
| 68 | +load_dotenv() |
| 69 | + |
| 70 | +conncreate = pyodbc.connect('driver={%s};server=%s;database=%s;uid=%s;pwd=%s' % |
| 71 | +( os.getenv('DRIVER'), os.getenv('SERVER'), os.getenv('DATABASE'), os.getenv('UID'), os.getenv('PASS') ) ) |
| 72 | + |
| 73 | +now = datetime.datetime.now().strftime("%d.%b %Y %H:%M:%S") |
| 74 | + |
| 75 | +client = discord.Client() |
| 76 | +bot = commands.Bot(command_prefix='!') |
| 77 | + |
| 78 | +@bot.event |
| 79 | +async def on_ready(): |
| 80 | + print('[%s] ----- BOT ONLINE -----' % (now)) |
| 81 | + |
| 82 | + |
| 83 | +@bot.command(name='createinv') |
| 84 | +async def createinv(ctx): |
| 85 | + #creating invite link |
| 86 | + invitelink = await ctx.channel.create_invite(max_uses=1,unique=True) |
| 87 | + sender = ctx.message.author |
| 88 | + #removing the url |
| 89 | + discordlink = invitelink.url |
| 90 | + invlink = discordlink.replace("https://discord.gg/","") |
| 91 | + #storing in db |
| 92 | + cursor = conncreate |
| 93 | + cursor.execute("INSERT INTO dbo.discordinv (invlink) VALUES (?)", invlink) |
| 94 | + cursor.commit() |
| 95 | + sender = ctx.message.author |
| 96 | + print('[%s][%s] has created an invite link: %s' % (now,sender,invitelink.url)) |
| 97 | + await ctx.send(invitelink) |
| 98 | + |
| 99 | +bot.run(os.getenv('TOKEN')) |
| 100 | +>>>>>>> 40913dfe7853f7c02faff48a8b435e4283af5f3d |
0 commit comments