Compare commits

..

10 Commits

Author SHA1 Message Date
7238ccca34 - Got rid of duplicate Token Import
- Moved the code around a little to read like:
Imports → Load environment → Declare globals → Load bad words → Events/commands → DB setup → Helper functions → Run bot.

This should make the code easier to read/follow while keeping related things closer together in the codebase.
2025-08-08 16:14:54 -05:00
4f442c2f92 Added cuss words as a txt file that cahces at bot startup. Also some regex stuff in there so it doesn't care about capitalization etc. 2025-08-07 23:54:07 -05:00
1109c2ef77 Test commit 2025-08-07 23:18:28 -05:00
1e358c1b2b Cleaned up the Git How-to a little and made infor more accurate 2025-08-07 23:04:41 -05:00
bfeb3594ec Added a git how to in our project for reference 2025-08-07 22:58:25 -05:00
b6c302d614 Johms fault 2025-08-07 22:55:07 -05:00
1afff33373 Merge branch 'master' of https://gitea.wheelytho.com/joshypoo/DiscordTipBot 2025-08-07 22:51:33 -05:00
ac3512900f Test Comment. Idk what is happening 2025-08-07 22:50:28 -05:00
c57426451d Merge branch 'master' of https://gitea.wheelytho.com/joshypoo/DiscordTipBot 2025-08-07 22:31:16 -05:00
7ea4b47d69 Added another test comment for git 2025-08-07 22:29:36 -05:00
3 changed files with 119 additions and 20 deletions

64
How_To_git101.txt Normal file
View File

@@ -0,0 +1,64 @@
📜 Git Basics for Our Discord Bot Project
(so we dont 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 youre on the right branch
Check which branch youre on:
git branch
If you see * master, youre 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
View File

@@ -5,14 +5,13 @@ from dotenv import load_dotenv
from pathlib import Path from pathlib import Path
import os import os
import sqlite_utils import sqlite_utils
import re
# Show the path we expect to load # Show the path we expect to load
# Explicitly find the .env file in the same directory as the script # Explicitly find the .env file in the same directory as the script
env_path = Path(__file__).resolve().parent / ".env" env_path = Path(__file__).resolve().parent / ".env"
print(f"Looking for .env at: {env_path}") print(f"Looking for .env at: {env_path}")
# Load the env file # Load the env file
load_dotenv(dotenv_path=env_path) load_dotenv(dotenv_path=env_path)
@@ -23,15 +22,23 @@ print(f"Loaded token Succesfully")
if token is None: if token is None:
raise RuntimeError(".env file not loaded or DISCORD_TOKEN not set.") 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') handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
intents = discord.Intents.default() intents = discord.Intents.default()
intents.message_content = True intents.message_content = True
intents.members = True intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents) 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 @bot.event
async def on_ready(): async def on_ready():
print(f"{bot.user.name} is ready") print(f"{bot.user.name} is ready")
@@ -45,16 +52,21 @@ async def on_ready():
@bot.event @bot.event
async def on_member_join(member): 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 @bot.event
async def on_message(message): async def on_message(message):
if message.author == bot.user: if message.author == bot.user:
return return
if "shit" in message.content.lower(): # Check if message contains a bad word
#await message.delete() if bad_words_pattern.search(message.content):
await message.channel.send(f"{message.author.mention} - bro thats a bad worddddd!") await message.channel.send(
f"{message.author.mention} - bro thats a bad worddddd!"
)
await bot.process_commands(message) 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) 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

33
bad_words.txt Normal file
View 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