Compare commits
2 Commits
177374a894
...
74da1235b4
Author | SHA1 | Date |
---|---|---|
Stefano Assenzo | 74da1235b4 | |
Stefano Assenzo | c6b54bda37 |
|
@ -0,0 +1,14 @@
|
||||||
|
from discord import Option
|
||||||
|
import discord
|
||||||
|
|
||||||
|
bot = discord.Bot()
|
||||||
|
|
||||||
|
|
||||||
|
@bot.slash_command()
|
||||||
|
@discord.default_permissions(ban_members = True, administrator = True)
|
||||||
|
async def ban_user(bot, ctx, member: Option(discord.Member, description="Select a member", required=True), reason: Option(str, description="Reason", required=True)):
|
||||||
|
try:
|
||||||
|
await member.ban(reason=reason)
|
||||||
|
await ctx.respond(f'{member.mention} has been banned!')
|
||||||
|
except:
|
||||||
|
await ctx.respond(f'{member.mention} has not been banned!')
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
bot = discord.Bot()
|
||||||
|
|
||||||
|
@bot.slash_command()
|
||||||
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@commands.cooldown(1, 5, commands.BucketType.user)
|
||||||
|
async def clear_messages(ctx, amount : int):
|
||||||
|
await ctx.channel.purge(limit=amount+1)
|
||||||
|
await ctx.respond('Messages have been cleared!')
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
bot = discord.Bot()
|
||||||
|
|
||||||
|
@bot.slash_command()
|
||||||
|
@discord.default_permissions(kick_members = True, administrator = True)
|
||||||
|
async def kick_user(bot, ctx, member : discord.Member, *, reason=None):
|
||||||
|
try:
|
||||||
|
await member.kick(reason=reason)
|
||||||
|
await ctx.respond(f'{member.mention} has been kicked!')
|
||||||
|
except:
|
||||||
|
await ctx.respond(f'{member.mention} has not been kicked!')
|
|
@ -1,40 +1,41 @@
|
||||||
|
from commands.moderation import ban, kick, clear_msg
|
||||||
|
from discord.commands.context import ApplicationContext # Discord
|
||||||
|
from selenium.webdriver.firefox.options import Options # Selenium
|
||||||
|
from discord.commands import Option # Discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from bson.objectid import ObjectId # MongoDB
|
||||||
|
from selenium import webdriver # Selenium
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from bson.objectid import ObjectId
|
from selenium import webdriver # Selenium
|
||||||
|
from discord.ext import tasks # Discord
|
||||||
from selenium.webdriver.firefox.options import Options
|
import urllib.parse # MongoDB
|
||||||
from selenium.webdriver.common.by import By
|
import datetime # Date
|
||||||
from selenium import webdriver
|
import discord # Discord
|
||||||
|
import pymongo # MongoDB
|
||||||
from discord.ext import tasks, commands
|
import time # Time
|
||||||
from discord.commands.context import ApplicationContext
|
import os # OS
|
||||||
from discord.commands import Option
|
|
||||||
import discord
|
|
||||||
import pymongo
|
|
||||||
import urllib.parse
|
|
||||||
from selenium import webdriver
|
|
||||||
import datetime
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
# .env
|
||||||
load_dotenv() # Load .env file
|
load_dotenv() # Load .env file
|
||||||
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') # Discord token
|
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN') # Discord token
|
||||||
GENERAL_ID = os.getenv('GENERAL_ID') # Channel ID
|
GENERAL_ID = os.getenv('GENERAL_ID') # Channel ID
|
||||||
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') # Password for MongoDB
|
PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') # Password for MongoDB
|
||||||
URL_MONGODB = os.getenv('URL_MONGODB') # URL for MongoDB
|
URL_MONGODB = os.getenv('URL_MONGODB') # URL for MongoDB
|
||||||
|
|
||||||
|
# MongoDB
|
||||||
mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB # URL for MongoDB (with password)
|
mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB # URL for MongoDB (with password)
|
||||||
client = pymongo.MongoClient(mongo_url) # Connect to MongoDB
|
client = pymongo.MongoClient(mongo_url) # Connect to MongoDB
|
||||||
database = client["website-class"] # Database name
|
database = client["website-class"] # Database name
|
||||||
# Collection school time table current
|
collection = database["school-time-table"] # Collection school time table current
|
||||||
collection = database["school-time-table"]
|
|
||||||
|
|
||||||
#Date
|
#Date
|
||||||
current_time = datetime.datetime.now()
|
current_time = datetime.datetime.now() # Current time
|
||||||
day = str(current_time.day)
|
day = str(current_time.day) # Day
|
||||||
month = str(current_time.month)
|
month = str(current_time.month) # Month
|
||||||
year = str(current_time.year)
|
year = str(current_time.year) # Year
|
||||||
hour = str(current_time.hour)
|
hour = str(current_time.hour) # Hour
|
||||||
minute = str(current_time.minute)
|
minute = str(current_time.minute) # Minute
|
||||||
long_date = day + "-" + month + "-" + year + " " + hour + ":" + minute
|
long_date = day + "-" + month + "-" + year + " " + hour + ":" + minute # Long date with day, month, year, hour and minute
|
||||||
|
|
||||||
bot = discord.Bot()
|
bot = discord.Bot()
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ async def on_ready():
|
||||||
async def orario():
|
async def orario():
|
||||||
documents = collection.find()
|
documents = collection.find()
|
||||||
send_screenshot = 0
|
send_screenshot = 0
|
||||||
|
|
||||||
# Iterate through the documents
|
# Iterate through the documents
|
||||||
for document in documents:
|
for document in documents:
|
||||||
for day in document['School Subject']:
|
for day in document['School Subject']:
|
||||||
|
@ -117,4 +119,20 @@ async def change_school_time(
|
||||||
{"$set": {f"School Subject.{day}.{int(hour_school)}.Subject": text}}
|
{"$set": {f"School Subject.{day}.{int(hour_school)}.Subject": text}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@bot.slash_command()
|
||||||
|
@discord.default_permissions(ban_members = True, administrator = True)
|
||||||
|
async def ban(ctx, member: Option(discord.Member, description="Select a member", required=True), reason: Option(str, description="Reason", required=True)):
|
||||||
|
ban.ban_user(bot, ctx, member, reason)
|
||||||
|
|
||||||
|
@bot.slash_command()
|
||||||
|
@discord.default_permissions(kick_members = True, administrator = True)
|
||||||
|
async def kick(ctx, member: Option(discord.Member, description="Select a member", required=True), reason: Option(str, description="Reason", required=True)):
|
||||||
|
kick.kick_user(bot, ctx, member, reason)
|
||||||
|
|
||||||
|
@bot.slash_command(name= 'clear', description= 'Clears messages from a channel')
|
||||||
|
@commands.has_permissions(manage_messages=True, administrator=True)
|
||||||
|
@commands.cooldown(1, 5, commands.BucketType.user)
|
||||||
|
async def clear(ctx, messages: Option(int, description="Amount of messages to delete", required=True)):
|
||||||
|
clear_msg.clear_messages(ctx, amount = messages)
|
||||||
|
|
||||||
bot.run(DISCORD_TOKEN)
|
bot.run(DISCORD_TOKEN)
|
|
@ -1,6 +1,8 @@
|
||||||
|
from dotenv import load_dotenv
|
||||||
from twilio.rest import Client
|
from twilio.rest import Client
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
SID = os.getenv('SID')
|
SID = os.getenv('SID')
|
||||||
AUTH_TOKEN = os.getenv('AUTHTOKEN')
|
AUTH_TOKEN = os.getenv('AUTHTOKEN')
|
||||||
PHONE_NUMBER_BOT = os.getenv('PHONE_NUMBER_BOT')
|
PHONE_NUMBER_BOT = os.getenv('PHONE_NUMBER_BOT')
|
||||||
|
|
Loading…
Reference in New Issue