-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made with ❤️ and everything in English
- Loading branch information
1 parent
14d5cc2
commit 3bebee8
Showing
11 changed files
with
1,010 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@tasks.loop(seconds=10) | ||
async def cdeletecommandclear(self): | ||
channel = self.bot.get_channel('CHANNEL_ID') | ||
messages = await channel.history(limit=200).flatten() | ||
for message in messages: | ||
if message.pinned: | ||
pass | ||
|
||
|
||
else: | ||
await message.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import discord | ||
from discord.ext import commands | ||
from discord.commands import slash_command, Option | ||
|
||
class Clear(commands.Cog): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
@commands.Cog.listener() | ||
async def on_ready(self): | ||
print(" ✅ - Der Clear Command wurde geladen.") | ||
async def on_application_command_error(self, ctx, error): | ||
if isinstance(error, commands.CheckFailure): | ||
await ctx.respond(f"› Du hast keine Berechtigungen um diesen Befehl auszuführen.", ephemeral=True) | ||
return | ||
|
||
await ctx.respond(f"Es ist ein Fehler aufgetreten: {error}", ephemeral=True) | ||
raise error | ||
|
||
|
||
|
||
@slash_command(description='› Lösche eine bestimmte Anzahl an Nachrichten.') | ||
@commands.has_permissions(manage_messages=True) | ||
@discord.guild_only() | ||
async def clear(self, ctx, | ||
amount: Option(int, "› Die Anzahl der Nachrichten, die du löschen möchtest:", required=True)): | ||
await ctx.channel.purge(limit=amount) | ||
await ctx.respond(f"› Es wurden erfolgreich **{amount}** Nachrichten gelöscht.", delete_after=3) | ||
|
||
def setup(bot): | ||
bot.add_cog(Clear(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import asyncio | ||
import os | ||
import discord | ||
from discord.ext import commands | ||
from dotenv import load_dotenv | ||
from discord import app_commands | ||
intents = discord.Intents.default() | ||
intents.message_content = True | ||
intents.members = True | ||
|
||
status = discord.Status.online | ||
activity = discord.Activity(type=discord.ActivityType.playing, name=":O") | ||
|
||
|
||
client = commands.Bot( | ||
intents=intents, | ||
status=status, | ||
activity=activity, | ||
command_prefix="-", | ||
) | ||
|
||
|
||
|
||
|
||
@client.event | ||
async def on_ready(): | ||
print(f"{client.user} Online") | ||
await client.tree.sync() | ||
|
||
async def funktion(): | ||
for filename in os.listdir('./cogs'): | ||
if filename.endswith('.py'): | ||
await client.load_extension(f'cogs.{filename[:-3]}') | ||
|
||
asyncio.run(funktion()) | ||
|
||
|
||
|
||
|
||
|
||
|
||
load_dotenv() | ||
client.run(os.getenv("TOKEN")) | ||
|
||
#from lucky |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import discord | ||
import asyncio | ||
# nur nötig wenn connect hier in der selben datei ist | ||
# import contextlib | ||
|
||
from discord import InputTextStyle | ||
from discord.ext.commands import MissingPermissions | ||
from discord.ext import commands, tasks | ||
from discord.ui import Button, View, Modal, InputText | ||
from discord.commands import Option, slash_command, SlashCommandGroup | ||
|
||
# from utils.funcs import get_config | ||
# from utils.funcs import connect | ||
# from utils.funcs import get_database_tables | ||
|
||
### {list(get_database_tables())[5]} das ist "counting" | ||
# connect ist: | ||
# @contextlib.asynccontextmanager | ||
# async def connect(): | ||
# conn = await aiomysql.connect( | ||
# host=get_config("mysql")["host"], | ||
# user=get_config("mysql")["user"], | ||
# password=get_config("mysql")["password"], | ||
# db=get_config("mysql")["database"], | ||
# autocommit=True | ||
# ) | ||
# async with conn.cursor() as cur: | ||
# yield conn, cur | ||
# conn.close() | ||
# | ||
# Datenbank structure | ||
# "guild_id": "BIGINT", | ||
# "counting_channel_id": "BIGINT", | ||
# "score": "BIGINT", | ||
# "highscore": "BIGINT", | ||
# "last_user": "BIGINT", | ||
# "fail_role": "BIGINT", | ||
# "only_numbers": "BOOLEAN" | ||
|
||
|
||
class counting(commands.Cog): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
|
||
counting_cmd = SlashCommandGroup(name="counting", description="All counting commands", guild_only=True) | ||
|
||
@counting_cmd.command() | ||
async def setchannel(self, ctx, channel: Option(discord.abc.GuildChannel, "Choose a Welcome Channel")): | ||
async with connect() as (conn, cur): | ||
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}") | ||
result_channel = await cur.fetchone() | ||
if not result_channel: | ||
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')") | ||
else: | ||
await cur.execute(f"UPDATE `counting` SET `counting_channel_id`='{channel.id}' WHERE guild_id = {ctx.guild.id}") | ||
return await ctx.respond(f"Der Counting-Channel wurde auf {channel.mention} Gesetzt", ephemeral=True) | ||
|
||
@counting_cmd.command() | ||
async def next(self, ctx): | ||
async with connect() as (conn, cur): | ||
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}") | ||
result_channel = await cur.fetchone() | ||
if not result_channel: | ||
return await ctx.respond(f"Nutze vorher /counting setchannel", ephemeral=True) | ||
await cur.execute(f"SELECT score FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}") | ||
next_int = await cur.fetchone() | ||
await cur.execute(f"SELECT last_user FROM {list(get_database_tables())[5]} WHERE guild_id = {ctx.guild.id}") | ||
next_user = await cur.fetchone() | ||
if next_user[0] == 0: | ||
return await ctx.respond(f"Die nächste Zahl ist {next_int[0]}!", ephemeral=True) | ||
else: | ||
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) | ||
|
||
@commands.Cog.listener() | ||
async def on_message(self, message): | ||
async with connect() as (conn, cur): | ||
if message.author.bot: | ||
return | ||
await cur.execute(f"SELECT counting_channel_id FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}") | ||
result_channel = await cur.fetchone() | ||
if not result_channel: | ||
return | ||
if message.channel.id == result_channel[0]: | ||
if message.author.bot: | ||
return | ||
await cur.execute(f"SELECT only_numbers FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}") | ||
num = await cur.fetchone() | ||
if num: | ||
if not message.content.isnumeric(): | ||
await asyncio.sleep(2) | ||
return await message.delete() | ||
if not message.content.isnumeric(): | ||
return | ||
await cur.execute(f"SELECT last_user FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}") | ||
last_user = await cur.fetchone() | ||
if message.author.id == int(last_user[0]): | ||
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)) | ||
await message.add_reaction("❌") | ||
channel = self.bot.get_channel(result_channel[0]) | ||
if channel: | ||
return await message.channel.send(F"{message.author.mention} hat die Reihe unterbrochen, da er versucht hat 2 mal hinter einander zu Zählen") | ||
else: | ||
await cur.execute(f"SELECT score FROM {list(get_database_tables())[5]} WHERE guild_id = {message.guild.id}") | ||
score_result = await cur.fetchone() | ||
if message.content == str(score_result[0]): | ||
count = score_result[0] + 1 | ||
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)) | ||
if score_result[0] < count: | ||
await cur.execute(f"UPDATE {list(get_database_tables())[5]} SET highscore = %s WHERE guild_id = %s", (message.content, message.guild.id)) | ||
return await message.add_reaction("✅") | ||
else: | ||
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)) | ||
return await message.add_reaction("❌") | ||
else: | ||
return | ||
|
||
def setup(bot): | ||
bot.add_cog(counting(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
############################################ | ||
# Discord Radio Bot | ||
# Author: @InvalidJoker | ||
# Version: 1.0 | ||
# Diese Nachricht darf nicht entfernt werden! | ||
############################################ | ||
from discord.ext import tasks | ||
import discord | ||
import asyncio | ||
|
||
CHANNEL = 1052660703267393567 | ||
|
||
bot = discord.Bot(intents=discord.Intents.all()) | ||
|
||
@bot.event | ||
async def on_ready(): | ||
channel = bot.get_channel(CHANNEL) | ||
|
||
await channel.connect() | ||
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3")) | ||
check_music.start() | ||
auto_restart.start() | ||
print("The Radio is online!") | ||
|
||
@tasks.loop(seconds=60) | ||
async def check_music(): | ||
channel = bot.get_channel(CHANNEL) | ||
|
||
if channel.guild.voice_client is None: | ||
await channel.connect() | ||
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3")) | ||
|
||
if channel.guild.voice_client.is_playing() == False: | ||
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3")) | ||
|
||
@tasks.loop(hours=24) | ||
async def auto_restart(): | ||
channel = bot.get_channel(CHANNEL) | ||
|
||
if channel.guild.voice_client: | ||
check_music.stop() | ||
await channel.guild.voice_client.disconnect() | ||
asyncio.sleep(5) | ||
await channel.connect() | ||
channel.guild.voice_client.play(discord.FFmpegPCMAudio("https://streams.ilovemusic.de/iloveradio16.mp3")) | ||
check_music.start() | ||
|
||
bot.run("TOKEN") |
Oops, something went wrong.