Skip to content

Commit a6c1e2a

Browse files
committed
fix !skin
1 parent 38ac58c commit a6c1e2a

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

partybot/cosmetic.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,23 @@ def __init__(self, bot: commands.Bot) -> None:
8080
async def skin(self, ctx: fortnitepy.ext.commands.Context, *, content: str) -> None:
8181
try:
8282
cosmetic = await self.bot.fortnite_api.cosmetics.get_cosmetic(
83-
lang="en",
84-
searchLang="en",
8583
matchMethod="contains",
8684
name=content,
8785
backendType="AthenaCharacter"
8886
)
87+
except FortniteAPIAsync.exceptions.NotFound:
88+
print(self.bot.message % f"Failed to find a skin with the name: {content}.")
89+
return await ctx.send(f"Failed to find a skin with the name: {content}.")
8990

90-
await ctx.send(f'Skin set to {cosmetic.id}.')
91-
print(self.bot.message % f"Set skin to: {cosmetic.id}.")
91+
if "brcosmetics" in cosmetic.path.lower():
92+
path = f"AthenaCharacterItemDefinition'/BRCosmetics/Athena/Items/Cosmetics/Characters/{cosmetic.id}.{cosmetic.id}'"
93+
await self.bot.party.me.set_outfit(asset=path)
94+
else:
9295
await self.bot.party.me.set_outfit(asset=cosmetic.id)
9396

94-
except FortniteAPIAsync.exceptions.NotFound:
95-
await ctx.send(f"Failed to find a skin with the name: {content}.")
96-
print(self.bot.message % f"Failed to find a skin with the name: {content}.")
97+
await ctx.send(f'Skin set to {cosmetic.id}.')
98+
print(self.bot.message % f"Set skin to: {cosmetic.id}.")
99+
97100

98101
@commands.dm_only()
99102
@commands.command(
@@ -104,21 +107,23 @@ async def skin(self, ctx: fortnitepy.ext.commands.Context, *, content: str) -> N
104107
async def backpack(self, ctx: fortnitepy.ext.commands.Context, *, content: str) -> None:
105108
try:
106109
cosmetic = await self.bot.fortnite_api.cosmetics.get_cosmetic(
107-
lang="en",
108-
searchLang="en",
109110
matchMethod="contains",
110111
name=content,
111112
backendType="AthenaBackpack"
112113
)
113-
114-
await ctx.send(f'Backpack set to {cosmetic.id}.')
115-
print(self.bot.message % f"Set backpack to: {cosmetic.id}.")
116-
await self.bot.party.me.set_backpack(asset=cosmetic.id)
117-
118114
except FortniteAPIAsync.exceptions.NotFound:
119115
await ctx.send(f"Failed to find a backpack with the name: {content}.")
120116
print(self.bot.message % f"Failed to find a backpack with the name: {content}.")
121117

118+
if "brcosmetics" in cosmetic.path.lower():
119+
path = f"AthenaCharacterItemDefinition'/BRCosmetics/Athena/Items/Cosmetics/Backpacks/{cosmetic.id}.{cosmetic.id}'"
120+
await self.bot.party.me.set_backpack(asset=path)
121+
else:
122+
await self.bot.party.me.set_outfit(asset=cosmetic.id)
123+
124+
await ctx.send(f'Backpack set to {cosmetic.id}.')
125+
print(self.bot.message % f"Set backpack to: {cosmetic.id}.")
126+
122127
@commands.dm_only()
123128
@commands.command(
124129
description="[Cosmetic] Sets the emote of the client using the emotes name.",
@@ -128,21 +133,24 @@ async def backpack(self, ctx: fortnitepy.ext.commands.Context, *, content: str)
128133
async def emote(self, ctx: fortnitepy.ext.commands.Context, *, content: str) -> None:
129134
try:
130135
cosmetic = await self.bot.fortnite_api.cosmetics.get_cosmetic(
131-
lang="en",
132-
searchLang="en",
133136
matchMethod="contains",
134137
name=content,
135138
backendType="AthenaDance"
136139
)
140+
except FortniteAPIAsync.exceptions.NotFound:
141+
await ctx.send(f"Failed to find an emote with the name: {content}.")
142+
print(self.bot.message % f"Failed to find an emote with the name: {content}.")
137143

138-
await ctx.send(f'Emote set to {cosmetic.id}.')
139-
print(self.bot.message % f"Set emote to: {cosmetic.id}.")
144+
if "brcosmetics" in cosmetic.path.lower():
145+
path = f"AthenaCharacterItemDefinition'/BRCosmetics/Athena/Items/Cosmetics/Dances/{cosmetic.id}.{cosmetic.id}'"
146+
await self.bot.party.me.clear_emote()
147+
await self.bot.party.me.set_emote(asset=path)
148+
else:
140149
await self.bot.party.me.clear_emote()
141150
await self.bot.party.me.set_emote(asset=cosmetic.id)
142151

143-
except FortniteAPIAsync.exceptions.NotFound:
144-
await ctx.send(f"Failed to find an emote with the name: {content}.")
145-
print(self.bot.message % f"Failed to find an emote with the name: {content}.")
152+
await ctx.send(f'Emote set to {cosmetic.id}.')
153+
print(self.bot.message % f"Set emote to: {cosmetic.id}.")
146154

147155
@commands.dm_only()
148156
@commands.command(

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ FortniteAPIAsync
66
aiofiles
77
cryptography==3.2.1
88
aioconsole
9+
pytz
10+
tzdata
11+
tzlocal

0 commit comments

Comments
 (0)