aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/filtering/filtering.py8
-rw-r--r--bot/exts/moderation/dm_relay.py8
-rw-r--r--bot/exts/moderation/metabase.py8
-rw-r--r--bot/exts/utils/internal.py8
-rw-r--r--bot/exts/utils/snekbox/_cog.py9
5 files changed, 21 insertions, 20 deletions
diff --git a/bot/exts/filtering/filtering.py b/bot/exts/filtering/filtering.py
index 173b220f8..47f0e898b 100644
--- a/bot/exts/filtering/filtering.py
+++ b/bot/exts/filtering/filtering.py
@@ -18,7 +18,7 @@ from discord.ext import commands, tasks
from discord.ext.commands import BadArgument, Cog, Context, command, has_any_role
from pydis_core.site_api import ResponseCodeError
from pydis_core.utils import scheduling
-from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, send_to_paste_service
+from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, PasteFile, send_to_paste_service
import bot
import bot.exts.filtering._ui.filter as filters_ui
@@ -1464,14 +1464,14 @@ class Filtering(Cog):
if e.code != 50035: # Content too long
raise
report = discord.utils.remove_markdown(report)
+ file = PasteFile(content=report, lexer="text")
try:
resp = await send_to_paste_service(
- contents=report,
+ files=[file],
http_session=self.bot.http_session,
- lexer="text",
paste_url=BaseURLs.paste_url,
)
- paste_resp = resp["link"]
+ paste_resp = resp.link
except (ValueError, PasteTooLongError, PasteUploadError):
paste_resp = ":warning: Failed to upload report to paste service"
file_buffer = io.StringIO(report)
diff --git a/bot/exts/moderation/dm_relay.py b/bot/exts/moderation/dm_relay.py
index e8c5a5428..6679af4cd 100644
--- a/bot/exts/moderation/dm_relay.py
+++ b/bot/exts/moderation/dm_relay.py
@@ -1,6 +1,6 @@
import discord
from discord.ext.commands import Cog, Context, command, has_any_role
-from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, send_to_paste_service
+from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, PasteFile, send_to_paste_service
from bot.bot import Bot
from bot.constants import BaseURLs, Emojis, MODERATION_ROLES
@@ -53,14 +53,14 @@ class DMRelay(Cog):
f"User: {user} ({user.id})\n"
f"Channel ID: {user.dm_channel.id}\n\n"
)
+ file = PasteFile(content=metadata+output, lexer="text")
try:
resp = await send_to_paste_service(
- contents=metadata + output,
- lexer="text",
+ files=[file],
http_session=self.bot.http_session,
paste_url=BaseURLs.paste_url,
)
- message = resp["link"]
+ message = resp.link
except PasteTooLongError:
message = f"{Emojis.cross_mark} Too long to upload to paste service."
except PasteUploadError:
diff --git a/bot/exts/moderation/metabase.py b/bot/exts/moderation/metabase.py
index 42e2342b5..5a5ca315b 100644
--- a/bot/exts/moderation/metabase.py
+++ b/bot/exts/moderation/metabase.py
@@ -9,7 +9,7 @@ from aiohttp.client_exceptions import ClientResponseError
from arrow import Arrow
from async_rediscache import RedisCache
from discord.ext.commands import Cog, Context, group, has_any_role
-from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, send_to_paste_service
+from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, PasteFile, send_to_paste_service
from pydis_core.utils.scheduling import Scheduler
from bot.bot import Bot
@@ -141,10 +141,10 @@ class Metabase(Cog):
# Format it nicely for human eyes
out = json.dumps(out, indent=4, sort_keys=True)
+ file = PasteFile(content=out, lexer=extension)
try:
resp = await send_to_paste_service(
- contents=out,
- lexer=extension,
+ files=[file],
http_session=self.bot.http_session,
paste_url=BaseURLs.paste_url,
)
@@ -153,7 +153,7 @@ class Metabase(Cog):
except PasteUploadError:
message = f":x: {ctx.author.mention} Failed to upload to paste service."
else:
- message = f":+1: {ctx.author.mention} Here's your link: {resp['link']}"
+ message = f":+1: {ctx.author.mention} Here's your link: {resp.link}"
await ctx.send(
f"{message}\nYou can also access this data within internal eval by doing: "
diff --git a/bot/exts/utils/internal.py b/bot/exts/utils/internal.py
index f2354983f..043105646 100644
--- a/bot/exts/utils/internal.py
+++ b/bot/exts/utils/internal.py
@@ -11,7 +11,7 @@ from typing import Any
import arrow
import discord
from discord.ext.commands import Cog, Context, group, has_any_role, is_owner
-from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, send_to_paste_service
+from pydis_core.utils.paste_service import PasteTooLongError, PasteUploadError, PasteFile, send_to_paste_service
from bot.bot import Bot
from bot.constants import BaseURLs, DEBUG_MODE, Roles
@@ -195,10 +195,10 @@ async def func(): # (None,) -> Any
truncate_index = newline_truncate_index
if len(out) > truncate_index:
+ file = PasteFile(content=out)
try:
resp = await send_to_paste_service(
- contents=out,
- lexer="python",
+ files=[file],
http_session=self.bot.http_session,
paste_url=BaseURLs.paste_url,
)
@@ -207,7 +207,7 @@ async def func(): # (None,) -> Any
except PasteUploadError:
paste_text = "failed to upload contents to paste service."
else:
- paste_text = f"full contents at {resp['link']}"
+ paste_text = f"full contents at {resp.link}"
await ctx.send(
f"```py\n{out[:truncate_index]}\n```"
diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py
index 0a3fbc62b..f8f32d06d 100644
--- a/bot/exts/utils/snekbox/_cog.py
+++ b/bot/exts/utils/snekbox/_cog.py
@@ -11,6 +11,7 @@ from typing import Literal, NamedTuple, TYPE_CHECKING
from discord import AllowedMentions, HTTPException, Interaction, Message, NotFound, Reaction, User, enums, ui
from discord.ext.commands import Cog, Command, Context, Converter, command, guild_only
from pydis_core.utils import interactions, paste_service
+from pydis_core.utils.paste_service import send_to_paste_service, PasteFile
from pydis_core.utils.regex import FORMATTED_CODE_REGEX, RAW_CODE_REGEX
from bot.bot import Bot
@@ -206,14 +207,14 @@ class Snekbox(Cog):
"""Upload the job's output to a paste service and return a URL to it if successful."""
log.trace("Uploading full output to paste service...")
+ file = PasteFile(content=output, lexer="text")
try:
- paste_link = await paste_service.send_to_paste_service(
- contents=output,
- lexer="text",
+ paste_response = await send_to_paste_service(
+ files=[file],
http_session=self.bot.http_session,
paste_url=BaseURLs.paste_url,
)
- return paste_link["link"]
+ return paste_response.link
except paste_service.PasteTooLongError:
return "too long to upload"
except paste_service.PasteUploadError: