Skip to content

Commit 36d6ac7

Browse files
committed
Added new Commands
1 parent 8d78ef1 commit 36d6ac7

5 files changed

Lines changed: 162 additions & 15 deletions

File tree

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
2-
mssql.py
3-
Logs/bot.log
4-
Logs/botlog.txt

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<<<<<<< HEAD
2+
## O2EZ BOT
3+
#Requirements
4+
[Python (3.9+)](https://www.python.org/downloads/)
5+
6+
#Installation
7+
We need a specific modules to be installed in order to run our bot.
8+
Open the Powershell and type each.
9+
```pip install -r requirements.txt```
10+
11+
if some modules are not installed correctly, try.
12+
```
13+
python pip install discord.py
14+
python pip install pyodbc
15+
python pip install python-dotenv
16+
```
17+
18+
Bot Token and Database Configs are found in `.emv` file.
19+
20+
21+
to run the bot, open powershell and type `python insert_bot_file_location` for example:
22+
```
23+
python e:/O2JAM/DiscordBot/bot.py
24+
```
25+
to close the bot, just ctrl+c in the powershell
26+
=======
27+
# O2EZ BOT
28+
29+
### Requirements
30+
31+
[Python (3.9+)](https://www.python.org/downloads/)
32+
33+
### Installation
34+
35+
We need a specific modules to be installed in order to run our bot.
36+
Open the Powershell and type.
37+
```pip install -r requirements.txt```
38+
39+
if some modules are not corectly installed, try.
40+
```
41+
python pip install discord.py
42+
python pip install pyodbc
43+
python pip install python-dotenv
44+
```
45+
46+
Bot Token and Database Configs are found in `.emv` file.
47+
48+
49+
to run the bot, open powershell and type `python insert_bot_file_location` for example:
50+
```
51+
python e:/O2JAM/DiscordBot/bot.py
52+
```
53+
to close the bot, just ctrl+c in the powershell
54+
>>>>>>> 40913dfe7853f7c02faff48a8b435e4283af5f3d

bot.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

mssql.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<<<<<<< HEAD
2+
discord.py==1.7.1
3+
pyodbc==4.0.30
4+
=======
5+
discord.py==1.7.1
6+
pyodbc==4.0.30
7+
>>>>>>> 40913dfe7853f7c02faff48a8b435e4283af5f3d
8+
python-dotenv==0.17.0

0 commit comments

Comments
 (0)