Compare commits
5 commits
ce3da3c91b
...
223b915d2d
Author | SHA1 | Date | |
---|---|---|---|
223b915d2d | |||
2b84f05eac | |||
62a354b8c7 | |||
dbe10c53d1 | |||
0c31c59017 |
5 changed files with 45 additions and 55 deletions
|
@ -13,6 +13,7 @@ class ExportChannels(commands.Cog):
|
|||
self.config.register_global(
|
||||
bot_token = None
|
||||
)
|
||||
self.data_path = data_manager.cog_data_path(self)
|
||||
|
||||
class ConfigException(Exception):
|
||||
pass
|
||||
|
@ -20,7 +21,7 @@ class ExportChannels(commands.Cog):
|
|||
async def export(self, channels: list):
|
||||
token = await self.config.bot_token()
|
||||
if token is None:
|
||||
raise(self.ConfigException, "Bot token not set!")
|
||||
raise(self.ConfigException("Bot token not set!"))
|
||||
data_path = data_manager.cog_data_path(self)
|
||||
bundled_data_path = data_manager.bundled_data_path(self)
|
||||
out = f'{data_path}{os.sep}Exported Channels'
|
||||
|
@ -71,12 +72,12 @@ class ExportChannels(commands.Cog):
|
|||
|
||||
@commands.group()
|
||||
@checks.is_owner()
|
||||
async def exportset(self, ctx):
|
||||
async def exportset(self, ctx: commands.Context):
|
||||
"""Configuration options for the ExportChannels cog."""
|
||||
|
||||
@exportset.command()
|
||||
@checks.is_owner()
|
||||
async def token(self, ctx, token: str):
|
||||
async def token(self, ctx: commands.Context, token: str):
|
||||
"""Sets the bot token used for Discord Chat Exporter."""
|
||||
await self.config.bot_token.set({token})
|
||||
await ctx.send(content="Token set!")
|
||||
|
@ -84,21 +85,18 @@ class ExportChannels(commands.Cog):
|
|||
|
||||
@exportset.command()
|
||||
@checks.is_owner()
|
||||
async def checkoutputpath(self, ctx):
|
||||
async def checkoutputpath(self, ctx: commands.Context):
|
||||
"""Checks what file path DCE is outputting to."""
|
||||
self.data_path = data_manager.cog_data_path(self)
|
||||
await ctx.send(content=f"{self.data_path}")
|
||||
|
||||
@commands.command()
|
||||
@commands.admin()
|
||||
async def exportchannel(self, ctx, channel: discord.TextChannel):
|
||||
async def exportchannel(self, ctx: commands.Context, channel: discord.TextChannel):
|
||||
"""Exports a channel using Discord Chat Exporter."""
|
||||
token = await self.config.bot_token()
|
||||
dce_install = data_manager.bundled_data_path(self)
|
||||
if token is None:
|
||||
await ctx.send(content=f"Please set your token with the ``{ctx.prefix}exportset token`` command!")
|
||||
return
|
||||
else:
|
||||
id_list = [thread.id for thread in channel.threads]
|
||||
id_list.insert(0, channel.id)
|
||||
await self.export(id_list)
|
||||
id_list = [thread.id for thread in channel.threads]
|
||||
id_list.insert(0, channel.id)
|
||||
await self.export(id_list)
|
||||
|
|
|
@ -275,16 +275,16 @@ class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
|||
|
||||
if embed.author.name == "Bot Bug Report":
|
||||
issue_title = f"[BOT BUG] {_issue_title}"
|
||||
desired_labels = ["bot", "bug"]
|
||||
# desired_labels = ["bot", "bug"]
|
||||
elif embed.author.name == "Bot Suggestion":
|
||||
issue_title = f"[BOT SUGGESTION] {_issue_title}"
|
||||
desired_labels = ["bot", "enhancement"]
|
||||
# desired_labels = ["bot", "enhancement"]
|
||||
elif embed.author.name == "Cog Bug Report":
|
||||
issue_title = f"[{field_values[0]}] {_issue_title}"
|
||||
desired_labels = ["cog", "bug"]
|
||||
# desired_labels = ["cog", "bug"]
|
||||
elif embed.author.name == "Cog Suggestion":
|
||||
issue_title = f"[{field_values[0]}] {_issue_title}"
|
||||
desired_labels = ["cog", "enhancement"]
|
||||
# desired_labels = ["cog", "enhancement"]
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {await self.config.gitea_token()}",
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import asyncio
|
||||
import re
|
||||
import discord
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
import discord
|
||||
from redbot.core import Config, checks, commands, data_manager
|
||||
from yt_dlp import YoutubeDL, utils
|
||||
from redbot.core import commands, checks, Config, data_manager
|
||||
|
||||
|
||||
class MusicDownloader(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
|
@ -39,7 +40,7 @@ class MusicDownloader(commands.Cog):
|
|||
db_path = os.path.join(data_path, "database.db")
|
||||
con = sqlite3.connect(db_path)
|
||||
cur = con.cursor()
|
||||
cur.execute(f"SELECT user_id, reason FROM blacklist_log WHERE user_id = ?;", (user_id,))
|
||||
cur.execute("SELECT user_id, reason FROM blacklist_log WHERE user_id = ?;", (user_id,))
|
||||
result = cur.fetchone()
|
||||
con.close()
|
||||
if result:
|
||||
|
@ -84,7 +85,7 @@ class MusicDownloader(commands.Cog):
|
|||
except self.UserBlacklisted as e:
|
||||
await ctx.send(f"You are blacklisted from running this command!\nReason: `{e}`")
|
||||
return
|
||||
def youtube_download(self, url: str, path: str, message: discord.Message):
|
||||
def youtube_download(self, url: str, path: str):
|
||||
"""This function does the actual downloading of the YouTube Video."""
|
||||
class Logger:
|
||||
def debug(self, msg):
|
||||
|
@ -108,14 +109,14 @@ class MusicDownloader(commands.Cog):
|
|||
with YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(url=url, download=False)
|
||||
title = info['title']
|
||||
id = info['id']
|
||||
filename = title + f' [{id}].m4a'
|
||||
Yid = info['id']
|
||||
filename = title + f' [{Yid}].m4a'
|
||||
full_filename = os.path.join(data_path, filename)
|
||||
if os.path.isfile(full_filename):
|
||||
previously_existed = True
|
||||
else:
|
||||
with YoutubeDL(ydl_opts) as ydl:
|
||||
error_code = ydl.download(url)
|
||||
ydl.download(url)
|
||||
previously_existed = False
|
||||
return filename, previously_existed
|
||||
data_path = await self.config.save_directory()
|
||||
|
@ -126,10 +127,8 @@ class MusicDownloader(commands.Cog):
|
|||
pattern = "[" + re.escape(illegal_chars) + "]"
|
||||
modified_subfolder = re.sub(pattern, r'__**\g<0>**__', subfolder)
|
||||
await ctx.send(f"Your subfolder contains illegal characters: `{modified_subfolder}`")
|
||||
return
|
||||
elif os.path.isfile(data_path):
|
||||
await ctx.send("Your 'subfolder' is a file, not a directory!")
|
||||
return
|
||||
elif os.path.exists(data_path) is False:
|
||||
message = await ctx.send("Your subfolder does not exist yet, would you like to continue? It will be automatically created.")
|
||||
def check(message):
|
||||
|
@ -150,7 +149,7 @@ class MusicDownloader(commands.Cog):
|
|||
message = await msg("YouTube Downloader started!")
|
||||
try:
|
||||
ytdlp_output = youtube_download(self, url, data_path, message)
|
||||
except utils.DownloadError or utils.ExtractorError:
|
||||
except (utils.DownloadError, utils.ExtractorError):
|
||||
await message.edit(content="Please provide a link to YouTube and not another site.\nThe site you've linked to is known for using DRM protection, so MusicDownloader cannot download from it.")
|
||||
return
|
||||
full_filename = os.path.join(data_path, ytdlp_output[0])
|
||||
|
@ -185,7 +184,7 @@ class MusicDownloader(commands.Cog):
|
|||
cur.execute("SELECT user_id, reason FROM blacklist_log WHERE user_id = ?;", (user.id,))
|
||||
result = cur.fetchone()
|
||||
if result:
|
||||
user_id, reason = result
|
||||
reason = result
|
||||
await ctx.send(f"{user.mention} is in the blacklist for the following reason: `{reason}`", allowed_mentions = discord.AllowedMentions(users=False))
|
||||
else:
|
||||
await ctx.send(f"{user.mention} is not in the blacklist.", allowed_mentions = discord.AllowedMentions(users=False))
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import discord
|
||||
from datetime import datetime
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core import commands, checks, Config, bot
|
||||
from redbot.core import commands, checks, Config
|
||||
|
||||
class Podcast(commands.Cog):
|
||||
"""Provides a questions submission system for podcasts.
|
||||
|
@ -21,20 +18,19 @@ class Podcast(commands.Cog):
|
|||
)
|
||||
|
||||
@commands.command()
|
||||
async def podcast(self, ctx, question: str):
|
||||
async def podcast(self, ctx: commands.Context, question: str):
|
||||
"""Submits a question to the Podcast."""
|
||||
prefix = await self.bot.get_valid_prefixes()
|
||||
if await self.config.guild(ctx.guild).global_mode(True):
|
||||
submission_channel = bot.get_channel(await self.config.global_submission_channel())
|
||||
submission_channel = ctx.bot.get_channel(await self.config.global_submission_channel())
|
||||
blacklisted_users = await self.config.global_blacklisted_users()
|
||||
elif await self.config.guild(ctx.guild).global_mode(False):
|
||||
submission_channel = bot.get_channel(await self.config.guild(ctx.guild).submission_channel())
|
||||
submission_channel = ctx.bot.get_channel(await self.config.guild(ctx.guild).submission_channel())
|
||||
blacklisted_users = await self.config.guild(ctx.guild).blacklisted_users()
|
||||
else:
|
||||
return
|
||||
if ctx.author.id in blacklisted_users:
|
||||
await ctx.author.send(content=f"You are blacklisted from ``{prefix}podcast``!")
|
||||
return
|
||||
else:
|
||||
await submission_channel.send(content=f"{question}")
|
||||
await ctx.send(content="Question submitted!")
|
||||
|
@ -48,10 +44,10 @@ class Podcast(commands.Cog):
|
|||
@podcastset.command(name="global")
|
||||
async def set_global_mode(self, ctx, enabled: bool):
|
||||
"""Enables or disables global mode."""
|
||||
if enabled == True:
|
||||
if enabled is True:
|
||||
await self.config.guild(ctx.guild).global_mode.set(True)
|
||||
await ctx.send(content="``global_mode`` has been enabled.")
|
||||
elif enabled == False:
|
||||
elif enabled is False:
|
||||
await self.config.guild(ctx.guild).global_mode.set(False)
|
||||
await ctx.send(content="``global_mode`` has been disabled.")
|
||||
else:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import discord
|
||||
from pytimeparse2 import disable_dateutil, parse
|
||||
from discord import ui
|
||||
from discord.ext.commands import Bot
|
||||
from redbot.core import Config, commands, app_commands
|
||||
from pytimeparse2 import disable_dateutil, parse
|
||||
from redbot.core import Config, app_commands, commands
|
||||
|
||||
class Shortmute(commands.Cog):
|
||||
"""Allows staff members to shortmute individuals for up to 30 minutes, using Discord's Timeouts feature."""
|
||||
|
@ -43,7 +43,7 @@ class Shortmute(commands.Cog):
|
|||
if evidence_image and evidence_link:
|
||||
await interaction.response.send_message(content="You've provided both the `evidence_image` and the `evidence_link` arguments! Please only use one or the other.", ephemeral=True)
|
||||
return
|
||||
elif evidence_link:
|
||||
if evidence_link:
|
||||
evidence = evidence_link
|
||||
elif evidence_image:
|
||||
evidence = str(evidence_image)
|
||||
|
@ -70,7 +70,7 @@ class Shortmute(commands.Cog):
|
|||
if role in target.roles:
|
||||
await interaction.response.send_message(content="You're trying to shortmute someone who is immune from shortmuting.", ephemeral=True)
|
||||
return
|
||||
if duration == 1 or duration == -1:
|
||||
if duration in (1, -1):
|
||||
readable_duration = f"{duration} minute"
|
||||
else:
|
||||
readable_duration = f"{duration} minutes"
|
||||
|
@ -80,7 +80,7 @@ class Shortmute(commands.Cog):
|
|||
if duration > 30:
|
||||
await interaction.response.send_message(content=f"{readable_duration} is longer than the 30 minutes you are allowed to shortmute users for.", ephemeral=True)
|
||||
return
|
||||
elif duration < 1:
|
||||
if duration < 1:
|
||||
await interaction.response.send_message(content=f"Please shortmute the user for longer than {readable_duration}! The maximum duration is 30 minutes.", ephemeral=True)
|
||||
return
|
||||
if skip_confirmation is False:
|
||||
|
@ -104,7 +104,7 @@ class Shortmute(commands.Cog):
|
|||
dm_embed.set_image(url=evidence)
|
||||
try:
|
||||
await target.send(embed=dm_embed)
|
||||
except discord.HTTPException as error:
|
||||
except discord.HTTPException:
|
||||
await message.edit(content="Could not message the target, user most likely has Direct Messages disabled.")
|
||||
logging_channels_list = await self.config.guild(interaction.guild).logging_channels()
|
||||
if logging_channels_list:
|
||||
|
@ -124,12 +124,12 @@ class Shortmute(commands.Cog):
|
|||
self.config = Config.get_conf(None, cog_name='Shortmute', identifier=25781647388294)
|
||||
|
||||
@ui.button(label="Yes", style=discord.ButtonStyle.success)
|
||||
async def shortmute_button_yes(self, button: ui.Button, interaction: discord.Interaction):
|
||||
async def shortmute_button_yes(self, button: ui.Button, interaction: discord.Interaction): # pylint: disable=arguments-differ
|
||||
disable_dateutil()
|
||||
target = self.passed_info['target']
|
||||
target: discord.Member = self.passed_info['target']
|
||||
readable_duration = self.passed_info['readable_duration']
|
||||
reason = self.passed_info['reason']
|
||||
old_interaction = self.passed_info['interaction']
|
||||
reason: str = self.passed_info['reason']
|
||||
old_interaction: discord.Interaction = self.passed_info['interaction']
|
||||
color = self.passed_info['color']
|
||||
timedelta = self.passed_info['timedelta']
|
||||
evidence = self.passed_info['evidence']
|
||||
|
@ -146,7 +146,7 @@ class Shortmute(commands.Cog):
|
|||
dm_embed.set_image(url=evidence)
|
||||
try:
|
||||
await target.send(embed=dm_embed)
|
||||
except discord.HTTPException as error:
|
||||
except discord.HTTPException:
|
||||
await old_message.edit(content="Could not message the target, user most likely has Direct Messages disabled.")
|
||||
logging_channels_list = await self.config.guild(old_interaction.guild).logging_channels()
|
||||
if logging_channels_list:
|
||||
|
@ -159,8 +159,8 @@ class Shortmute(commands.Cog):
|
|||
await channel_obj.send(embed=logging_embed)
|
||||
|
||||
@ui.button(label="No", style=discord.ButtonStyle.danger)
|
||||
async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction):
|
||||
message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
||||
async def shortmute_button_no(self, button: ui.Button, interaction: discord.Interaction): # pylint: disable=arguments-differ
|
||||
message: discord.Message = await self.passed_info['interaction'].edit_original_response(content="Command cancelled.", view=None, embed=None)
|
||||
await message.delete(delay=3)
|
||||
|
||||
@commands.group(name='shortmuteset', autohelp=True)
|
||||
|
@ -190,11 +190,10 @@ class Shortmute(commands.Cog):
|
|||
@commands.admin()
|
||||
async def shortmute_config_channel_add(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||
"""Adds a channel to the logging channels list."""
|
||||
current_list = await self.config.guild(ctx.guild).logging_channels()
|
||||
current_list: list = await self.config.guild(ctx.guild).logging_channels()
|
||||
if channel:
|
||||
if channel.id in current_list:
|
||||
await ctx.send("This channel is already in the logging channel list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(channel.id)
|
||||
await self.config.guild(ctx.guild).logging_channels.set(current_list)
|
||||
|
@ -240,7 +239,6 @@ class Shortmute(commands.Cog):
|
|||
if role:
|
||||
if role.id in current_list:
|
||||
await ctx.send("This role is already in the immune roles list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(role.id)
|
||||
await self.config.guild(ctx.guild).immune_roles.set(current_list)
|
||||
|
@ -286,7 +284,6 @@ class Shortmute(commands.Cog):
|
|||
if user:
|
||||
if user.id in current_list:
|
||||
await ctx.send("That user is already in the blacklisted users list!")
|
||||
return
|
||||
else:
|
||||
current_list.append(user.id)
|
||||
await self.config.guild(ctx.guild).blacklisted_users.set(current_list)
|
||||
|
|
Loading…
Reference in a new issue