Skip to content

Commit 3bebee8

Browse files
authored
Made with ❤️ and everything in English
1 parent 14d5cc2 commit 3bebee8

File tree

11 files changed

+1010
-0
lines changed

11 files changed

+1010
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@tasks.loop(seconds=10)
2+
async def cdeletecommandclear(self):
3+
channel = self.bot.get_channel('CHANNEL_ID')
4+
messages = await channel.history(limit=200).flatten()
5+
for message in messages:
6+
if message.pinned:
7+
pass
8+
9+
10+
else:
11+
await message.delete()

Discord Codes/python/Clear Chat.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import discord
2+
from discord.ext import commands
3+
from discord.commands import slash_command, Option
4+
5+
class Clear(commands.Cog):
6+
def __init__(self, bot):
7+
self.bot = bot
8+
9+
@commands.Cog.listener()
10+
async def on_ready(self):
11+
print(" ✅ - Der Clear Command wurde geladen.")
12+
async def on_application_command_error(self, ctx, error):
13+
if isinstance(error, commands.CheckFailure):
14+
await ctx.respond(f"› Du hast keine Berechtigungen um diesen Befehl auszuführen.", ephemeral=True)
15+
return
16+
17+
await ctx.respond(f"Es ist ein Fehler aufgetreten: {error}", ephemeral=True)
18+
raise error
19+
20+
21+
22+
@slash_command(description='› Lösche eine bestimmte Anzahl an Nachrichten.')
23+
@commands.has_permissions(manage_messages=True)
24+
@discord.guild_only()
25+
async def clear(self, ctx,
26+
amount: Option(int, "› Die Anzahl der Nachrichten, die du löschen möchtest:", required=True)):
27+
await ctx.channel.purge(limit=amount)
28+
await ctx.respond(f"› Es wurden erfolgreich **{amount}** Nachrichten gelöscht.", delete_after=3)
29+
30+
def setup(bot):
31+
bot.add_cog(Clear(bot))
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import asyncio
2+
import os
3+
import discord
4+
from discord.ext import commands
5+
from dotenv import load_dotenv
6+
from discord import app_commands
7+
intents = discord.Intents.default()
8+
intents.message_content = True
9+
intents.members = True
10+
11+
status = discord.Status.online
12+
activity = discord.Activity(type=discord.ActivityType.playing, name=":O")
13+
14+
15+
client = commands.Bot(
16+
intents=intents,
17+
status=status,
18+
activity=activity,
19+
command_prefix="-",
20+
)
21+
22+
23+
24+
25+
@client.event
26+
async def on_ready():
27+
print(f"{client.user} Online")
28+
await client.tree.sync()
29+
30+
async def funktion():
31+
for filename in os.listdir('./cogs'):
32+
if filename.endswith('.py'):
33+
await client.load_extension(f'cogs.{filename[:-3]}')
34+
35+
asyncio.run(funktion())
36+
37+
38+
39+
40+
41+
42+
load_dotenv()
43+
client.run(os.getenv("TOKEN"))
44+
45+
#from lucky

Discord Codes/python/Counting Game.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import discord
2+
import asyncio
3+
# nur nötig wenn connect hier in der selben datei ist
4+
# import contextlib
5+
6+
from discord import InputTextStyle
7+
from discord.ext.commands import MissingPermissions
8+
from discord.ext import commands, tasks
9+
from discord.ui import Button, View, Modal, InputText
10+
from discord.commands import Option, slash_command, SlashCommandGroup
11+
12+
# from utils.funcs import get_config
13+
# from utils.funcs import connect
14+
# from utils.funcs import get_database_tables
15+
16+
### {list(get_database_tables())[5]} das ist "counting"
17+
# connect ist:
18+
# @contextlib.asynccontextmanager
19+
# async def connect():
20+
# conn = await aiomysql.connect(
21+
# host=get_config("mysql")["host"],
22+
# user=get_config("mysql")["user"],
23+
# password=get_config("mysql")["password"],
24+
# db=get_config("mysql")["database"],
25+
# autocommit=True
26+
# )
27+
# async with conn.cursor() as cur:
28+
# yield conn, cur
29+
# conn.close()
30+
#
31+
# Datenbank structure
32+
# "guild_id": "BIGINT",
33+
# "counting_channel_id": "BIGINT",
34+
# "score": "BIGINT",
35+
# "highscore": "BIGINT",
36+
# "last_user": "BIGINT",
37+
# "fail_role": "BIGINT",
38+
# "only_numbers": "BOOLEAN"
39+
40+
41+
class counting(commands.Cog):
42+
def __init__(self, bot):
43+
self.bot = bot
44+
45+
46+
counting_cmd = SlashCommandGroup(name="counting", description="All counting commands", guild_only=True)
47+
48+
@counting_cmd.command()
49+
async def setchannel(self, ctx, channel: Option(discord.abc.GuildChannel, "Choose a Welcome Channel")):
50+
async with connect() as (conn, cur):
51+
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}")
52+
result_channel = await cur.fetchone()
53+
if not result_channel:
54+
await cur.execute(f"INSERT INTO `counting`(`guild_id`, `counting_channel_id`, `score`, `highscore`, `last_user`, `only_numbers`) VALUES ('{ctx.guild.id}','{channel.id}','1','0','0','0')")
55+
else:
56+
await cur.execute(f"UPDATE `counting` SET `counting_channel_id`='{channel.id}' WHERE guild_id = {ctx.guild.id}")
57+
return await ctx.respond(f"Der Counting-Channel wurde auf {channel.mention} Gesetzt", ephemeral=True)
58+
59+
@counting_cmd.command()
60+
async def next(self, ctx):
61+
async with connect() as (conn, cur):
62+
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}")
63+
result_channel = await cur.fetchone()
64+
if not result_channel:
65+
return await ctx.respond(f"Nutze vorher /counting setchannel", ephemeral=True)
66+
await cur.execute(f"SELECT score FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}")
67+
next_int = await cur.fetchone()
68+
await cur.execute(f"SELECT last_user FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}")
69+
next_user = await cur.fetchone()
70+
if next_user[0] == 0:
71+
return await ctx.respond(f"Die nächste Zahl ist {next_int[0]}!", ephemeral=True)
72+
else:
73+
return await ctx.respond(f"Die nächste Zahl ist {next_int[0]} und der User <@{next_user[0]}> darf nicht als nächstes Zählen!", ephemeral=True)
74+
75+
@commands.Cog.listener()
76+
async def on_message(self, message):
77+
async with connect() as (conn, cur):
78+
if message.author.bot:
79+
return
80+
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}")
81+
result_channel = await cur.fetchone()
82+
if not result_channel:
83+
return
84+
if message.channel.id == result_channel[0]:
85+
if message.author.bot:
86+
return
87+
await cur.execute(f"SELECT only_numbers FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}")
88+
num = await cur.fetchone()
89+
if num:
90+
if not message.content.isnumeric():
91+
await asyncio.sleep(2)
92+
return await message.delete()
93+
if not message.content.isnumeric():
94+
return
95+
await cur.execute(f"SELECT last_user FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}")
96+
last_user = await cur.fetchone()
97+
if message.author.id == int(last_user[0]):
98+
await cur.execute(f"UPDATE {list(get_database_tables())[5]} SET score = %s, last_user = %s WHERE guild_id = %s", ("1", "0", message.guild.id))
99+
await message.add_reaction("❌")
100+
channel = self.bot.get_channel(result_channel[0])
101+
if channel:
102+
return await message.channel.send(F"{message.author.mention} hat die Reihe unterbrochen, da er versucht hat 2 mal hinter einander zu Zählen")
103+
else:
104+
await cur.execute(f"SELECT score FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}")
105+
score_result = await cur.fetchone()
106+
if message.content == str(score_result[0]):
107+
count = score_result[0] + 1
108+
await cur.execute(f"UPDATE {list(get_database_tables())[5]} SET score = %s, last_user = %s WHERE guild_id = %s", (count, message.author.id, message.guild.id))
109+
if score_result[0] < count:
110+
await cur.execute(f"UPDATE {list(get_database_tables())[5]} SET highscore = %s WHERE guild_id = %s", (message.content, message.guild.id))
111+
return await message.add_reaction("✅")
112+
else:
113+
await cur.execute(f"UPDATE {list(get_database_tables())[5]} SET score = %s, last_user = %s WHERE guild_id = %s", ("1", "0", message.guild.id))
114+
return await message.add_reaction("❌")
115+
else:
116+
return
117+
118+
def setup(bot):
119+
bot.add_cog(counting(bot))

Discord Codes/python/Radio.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
############################################
2+
# Discord Radio Bot
3+
# Author: @InvalidJoker
4+
# Version: 1.0
5+
# Diese Nachricht darf nicht entfernt werden!
6+
############################################
7+
from discord.ext import tasks
8+
import discord
9+
import asyncio
10+
11+
CHANNEL = 1052660703267393567
12+
13+
bot = discord.Bot(intents=discord.Intents.all())
14+
15+
@bot.event
16+
async def on_ready():
17+
channel = bot.get_channel(CHANNEL)
18+
19+
await channel.connect()
20+
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3"))
21+
check_music.start()
22+
auto_restart.start()
23+
print("The Radio is online!")
24+
25+
@tasks.loop(seconds=60)
26+
async def check_music():
27+
channel = bot.get_channel(CHANNEL)
28+
29+
if channel.guild.voice_client is None:
30+
await channel.connect()
31+
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3"))
32+
33+
if channel.guild.voice_client.is_playing() == False:
34+
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3"))
35+
36+
@tasks.loop(hours=24)
37+
async def auto_restart():
38+
channel = bot.get_channel(CHANNEL)
39+
40+
if channel.guild.voice_client:
41+
check_music.stop()
42+
await channel.guild.voice_client.disconnect()
43+
asyncio.sleep(5)
44+
await channel.connect()
45+
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3"))
46+
check_music.start()
47+
48+
bot.run("TOKEN")

0 commit comments

Comments
 (0)