Compare commits
10 Commits
501f703048
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7238ccca34 | |||
| 4f442c2f92 | |||
| 1109c2ef77 | |||
| 1e358c1b2b | |||
| bfeb3594ec | |||
| b6c302d614 | |||
| 1afff33373 | |||
| ac3512900f | |||
| c57426451d | |||
| 7ea4b47d69 |
64
How_To_git101.txt
Normal file
64
How_To_git101.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
📜 Git Basics for Our Discord Bot Project
|
||||
(so we don’t break things accidentally)
|
||||
|
||||
|
||||
1️⃣ Cloning the repo (***first time setup***)
|
||||
|
||||
Run this in your terminal:
|
||||
|
||||
git clone https://gitea.wheelytho.com/joshypoo/DiscordTipBot
|
||||
|
||||
This creates a folder with all the files and already sets up the remote.
|
||||
|
||||
|
||||
2️⃣ Making sure you’re on the right branch
|
||||
|
||||
Check which branch you’re on:
|
||||
|
||||
git branch
|
||||
|
||||
If you see * master, you’re good.
|
||||
|
||||
|
||||
3️⃣ Pulling latest changes from Gitea
|
||||
|
||||
Before making edits:
|
||||
|
||||
git pull
|
||||
|
||||
If it gives an error like “no tracking information”, link the branch:
|
||||
|
||||
git branch --set-upstream-to=origin/master master
|
||||
|
||||
|
||||
4️⃣ Making changes & committing
|
||||
|
||||
After editing files:
|
||||
|
||||
git add .
|
||||
git commit -m "Describe what you changed"
|
||||
|
||||
|
||||
5️⃣ Pushing your changes to Gitea
|
||||
|
||||
git push
|
||||
|
||||
|
||||
6️⃣ The golden rule
|
||||
|
||||
Always git pull before you start making changes.
|
||||
It avoids merge conflicts and sadness.
|
||||
|
||||
|
||||
7️⃣ VS Code Tip
|
||||
|
||||
The Source Control tab (Ctrl+Shift+G) lets you stage, commit, and push without typing commands.
|
||||
|
||||
The Sync Changes button does a push + pull together — good for quick updates.
|
||||
|
||||
If anyone gets really stuck, we can reset their local copy with:
|
||||
|
||||
git fetch origin
|
||||
git reset --hard origin/master
|
||||
|
||||
⚠ This will erase local changes — use only if you want a clean slate.
|
||||
42
Main.py
42
Main.py
@@ -5,14 +5,13 @@ from dotenv import load_dotenv
|
||||
from pathlib import Path
|
||||
import os
|
||||
import sqlite_utils
|
||||
import re
|
||||
|
||||
# Show the path we expect to load
|
||||
# Explicitly find the .env file in the same directory as the script
|
||||
|
||||
env_path = Path(__file__).resolve().parent / ".env"
|
||||
print(f"Looking for .env at: {env_path}")
|
||||
|
||||
|
||||
# Load the env file
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
@@ -23,15 +22,23 @@ print(f"Loaded token Succesfully")
|
||||
if token is None:
|
||||
raise RuntimeError(".env file not loaded or DISCORD_TOKEN not set.")
|
||||
|
||||
token = os.getenv("DISCORD_TOKEN")
|
||||
|
||||
### Declare generic and global variables here ###
|
||||
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
intents.members = True
|
||||
|
||||
bot = commands.Bot(command_prefix='!', intents=intents)
|
||||
|
||||
# --- Load bad words from file into a set when the bot starts,
|
||||
# --- this makes the file accessed only once each time the bot runs,
|
||||
# --- as oppsoed to checking the txt file every time a discord message comes though ---
|
||||
with open("bad_words.txt", "r", encoding="utf-8") as f:
|
||||
BAD_WORDS = {line.strip().lower() for line in f if line.strip()}
|
||||
|
||||
# Compile regex pattern for performance
|
||||
# \b = word boundary, (?i) = case-insensitive
|
||||
bad_words_pattern = re.compile(r"\b(" + "|".join(map(re.escape, BAD_WORDS)) + r")\b", re.IGNORECASE)
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print(f"{bot.user.name} is ready")
|
||||
@@ -45,16 +52,21 @@ async def on_ready():
|
||||
|
||||
@bot.event
|
||||
async def on_member_join(member):
|
||||
await member.send(f"Welcome to the server {member.name}")
|
||||
await member.send(f"Welcome to the server {member.name}!")
|
||||
# Should we give new members some points just for joining so they can start off with something? - Joshypoo
|
||||
# we should also add users to the DB on member join, becasue we will get to a point where the bot isn't constantly restarting
|
||||
|
||||
#Responding to cuss words
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
if message.author == bot.user:
|
||||
return
|
||||
|
||||
if "shit" in message.content.lower():
|
||||
#await message.delete()
|
||||
await message.channel.send(f"{message.author.mention} - bro thats a bad worddddd!")
|
||||
# Check if message contains a bad word
|
||||
if bad_words_pattern.search(message.content):
|
||||
await message.channel.send(
|
||||
f"{message.author.mention} - bro that’s a bad worddddd!"
|
||||
)
|
||||
|
||||
await bot.process_commands(message)
|
||||
|
||||
@@ -150,14 +162,4 @@ async def points(ctx, member: discord.Member = None):
|
||||
|
||||
|
||||
|
||||
bot.run(token, log_handler=handler, log_level=logging.DEBUG)
|
||||
|
||||
#Aaron is fun but dumb
|
||||
#Didn't I say that Already "NO YOu SAiD BlAH BLaaah" Oh Wait I'm wrong babooo boo
|
||||
|
||||
# AAron does pay attention
|
||||
# John doesn't read the manual - true
|
||||
|
||||
|
||||
#wazzzzzzup
|
||||
# //testy
|
||||
bot.run(token, log_handler=handler, log_level=logging.DEBUG)
|
||||
33
bad_words.txt
Normal file
33
bad_words.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
ass
|
||||
asshole
|
||||
bastard
|
||||
bitch
|
||||
bollocks
|
||||
bugger
|
||||
bullshit
|
||||
crap
|
||||
cunt
|
||||
damn
|
||||
dick
|
||||
douche
|
||||
fag
|
||||
faggot
|
||||
fuck
|
||||
fucker
|
||||
fucking
|
||||
goddamn
|
||||
hell
|
||||
horseshit
|
||||
jackass
|
||||
jerk
|
||||
motherfucker
|
||||
piss
|
||||
prick
|
||||
pussy
|
||||
shit
|
||||
shithead
|
||||
slut
|
||||
sonofabitch
|
||||
twat
|
||||
wanker
|
||||
whore
|
||||
Reference in New Issue
Block a user