@@ -54,46 +54,3 @@ async def stopserver(ctx):
5454 await ctx .send ('[%s] has started the Server' % (ctx .message .author ))
5555
5656bot .run (os .getenv ('TOKEN' ))
57- == == == =
58- import os
59- import discord
60- import pyodbc
61- import time
62- import datetime
63-
64- from dotenv import load_dotenv
65- from discord .ext import commands
66-
67- load_dotenv ()
68-
69- conncreate = pyodbc .connect ('driver={%s};server=%s;database=%s;uid=%s;pwd=%s' %
70- ( os .getenv ('DRIVER' ), os .getenv ('SERVER' ), os .getenv ('DATABASE' ), os .getenv ('UID' ), os .getenv ('PASS' ) ) )
71-
72- now = datetime .datetime .now ().strftime ("%d.%b %Y %H:%M:%S" )
73-
74- client = discord .Client ()
75- bot = commands .Bot (command_prefix = '!' )
76-
77- @bot .event
78- async def on_ready ():
79- print ('[%s] ----- BOT ONLINE -----' % (now ))
80-
81-
82- @bot .command (name = 'createinv' )
83- async def createinv (ctx ):
84- #creating invite link
85- invitelink = await ctx .channel .create_invite (max_uses = 1 ,unique = True )
86- sender = ctx .message .author
87- #removing the url
88- discordlink = invitelink .url
89- invlink = discordlink .replace ("https://discord.gg/" ,"" )
90- #storing in db
91- cursor = conncreate
92- cursor .execute ("INSERT INTO dbo.discordinv (invlink) VALUES (?)" , invlink )
93- cursor .commit ()
94- sender = ctx .message .author
95- print ('[%s][%s] has created an invite link: %s' % (now ,sender ,invitelink .url ))
96- await ctx .send (invitelink )
97-
98- bot .run (os .getenv ('TOKEN' ))
99- > >> >> >> 40913 dfe7853f7c02faff48a8b435e4283af5f3d
0 commit comments