Skip to content

Commit

Permalink
[AutoReact] actually save data in config
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Mar 19, 2024
1 parent 5d9e8e9 commit e6f1976
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions autoreact/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def _autoreact_add(
if trigger not in reactions:
reactions[trigger] = []
reactions[trigger].append(str(reaction))
await self.config.guild(ctx.guild).reaction.set(reactions)
if ctx.guild.id not in self.cache.autoreact:
self.cache.autoreact[ctx.guild.id] = {}
if trigger not in self.cache.autoreact[ctx.guild.id]:
Expand All @@ -63,6 +64,7 @@ async def _autoreact_add_images(self, ctx: commands.GuildContext, reaction: Emoj
if "images" not in event:
event["images"] = []
event["images"].append(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
if ctx.guild.id not in self.cache.event:
self.cache.event[ctx.guild.id] = {}
if "images" not in self.cache.event[ctx.guild.id]:
Expand All @@ -86,6 +88,7 @@ async def _autoreact_add_spoilers(self, ctx: commands.GuildContext, reaction: Em
if "spoilers" not in event:
event["spoilers"] = []
event["spoilers"].append(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
if ctx.guild.id not in self.cache.event:
self.cache.event[ctx.guild.id] = {}
if "spoilers" not in self.cache.event[ctx.guild.id]:
Expand All @@ -106,6 +109,7 @@ async def _autoreact_add_emojis(self, ctx: commands.GuildContext, reaction: Emoj
if "emojis" not in event:
event["emojis"] = []
event["emojis"].append(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
if ctx.guild.id not in self.cache.event:
self.cache.event[ctx.guild.id] = {}
if "emojis" not in self.cache.event[ctx.guild.id]:
Expand All @@ -129,6 +133,7 @@ async def _autoreact_add_stickers(self, ctx: commands.GuildContext, reaction: Em
if "stickers" not in event:
event["stickers"] = []
event["stickers"].append(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
if ctx.guild.id not in self.cache.event:
self.cache.event[ctx.guild.id] = {}
if "stickers" not in self.cache.event[ctx.guild.id]:
Expand All @@ -146,6 +151,7 @@ async def _autoreact_remove(
return
reactions: Dict[str, List[str]] = await self.config.guild(ctx.guild).reaction()
reactions[trigger].remove(str(reaction))
await self.config.guild(ctx.guild).reaction.set(reactions)
self.cache.autoreact[ctx.guild.id][trigger].remove(str(reaction))
await ctx.send("Successfully removed that auto reaction.")

Expand All @@ -157,6 +163,7 @@ async def _autoreact_remove_images(self, ctx: commands.GuildContext, reaction: E
return
event: Dict[str, List[str]] = await self.config.guild(ctx.guild).event()
event["images"].remove(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
self.cache.event[ctx.guild.id]["images"].remove(str(reaction))
await ctx.send("Successfully removed that auto reaction.")

Expand All @@ -170,6 +177,7 @@ async def _autoreact_remove_spoilers(
return
event: Dict[str, List[str]] = await self.config.guild(ctx.guild).event()
event["spoilers"].remove(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
self.cache.event[ctx.guild.id]["spoilers"].remove(str(reaction))
await ctx.send("Successfully removed that auto reaction.")

Expand All @@ -181,6 +189,7 @@ async def _autoreact_remove_emojis(self, ctx: commands.GuildContext, reaction: E
return
event: Dict[str, List[str]] = await self.config.guild(ctx.guild).event()
event["emojis"].remove(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
self.cache.event[ctx.guild.id]["emojis"].remove(str(reaction))
await ctx.send("Successfully removed that auto reaction.")

Expand All @@ -194,6 +203,7 @@ async def _autoreact_remove_stickers(
return
event: Dict[str, List[str]] = await self.config.guild(ctx.guild).event()
event["stickers"].remove(str(reaction))
await self.config.guild(ctx.guild).event.set(event)
self.cache.event[ctx.guild.id]["stickers"].remove(str(reaction))
await ctx.send("Successfully removed that auto reaction.")

Expand Down

0 comments on commit e6f1976

Please sign in to comment.