Skip to content

Commit

Permalink
Remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkyIsAKing committed Nov 29, 2024
1 parent df4d7ec commit df16ad5
Showing 1 changed file with 0 additions and 156 deletions.
156 changes: 0 additions & 156 deletions redbot/cogs/streams/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,162 +756,6 @@ async def remove_message(self, ctx: commands.Context, name: str, mention: str):
await self.save_streams()
await ctx.send(_("Removed message(s) from streamer `{}`").format(name))

@message.command(name="check")
@commands.guild_only()
async def check_messages(self, ctx: commands.Context, streamer_name: str):
"""
Use the command `[p]streamset message check <streamer_name>`
Red will respond with the message(s) associated with that streamer.
"""

for stream in self.streams:
if stream.name.lower() == streamer_name.lower():
try:
await ctx.send(
_("`{}`'s nomention message is set as: `{}`").format(
streamer_name, stream.nomention_message
)
)
except AttributeError:
await ctx.send(
_("`{}` does not have a nomention message.").format(streamer_name)
)
try:
await ctx.send(
_("`{}`'s mention message is set as: `{}` to `{}`").format(
streamer_name, stream.mention_message, stream.who_to_mention
)
)
except AttributeError:
await ctx.send(
_("`{}` does not have a mention message.").format(streamer_name)
)
return

await ctx.send(
_(
"Streamer `{}` is not registered and therefore does not have any custom messages."
).format(streamer_name)
)
return

# @checks.mod_or_permissions(manage_channels=True)
@message.command(name="streamer")
@commands.guild_only()
async def custom_message(
self,
ctx: commands.Context,
streamer_name: str,
mention: str,
to_mention: str = None,
*,
msg: str,
):
"""Set custom stream alert message for already-registered streamer.
Use the command `[p]streamset message streamer <streamer_name> <mention|nomention> [if_mention: audience] <message>`
Streamer must be already registered.
Command can be run by moderator.
Can only be used in server.
"""

# Change in the print statements way below too
streams_list = defaultdict(list)

# Verifying that the user is setting a message for an existing streamer
not_found = True
stream_id = ""
for stream in self.streams:
if stream.name.lower() == streamer_name.lower():
stream_id = stream.id
not_found = False
if mention == "mention":
stream.mention_message = msg
stream.who_to_mention = "@{}".format(to_mention)
await ctx.send(
_(
"Custom message for streamer `{}` set to mention @\u200b{}.".format(
streamer_name, to_mention
)
)
)
await self.save_streams()
break
elif mention == "nomention":
msg = to_mention + " " + msg
stream.nomention_message = msg
await ctx.send(
_("Custom nomention message streamer `{}` set".format(streamer_name))
)
await self.save_streams()
break
else:
await ctx.send_help()
break

if not_found:
await ctx.send(
_(
"Streamer `{}` not registered, please look at `[p]streamalert help`".format(
streamer_name
)
)
)
return

@message.command(name="remove")
@commands.guild_only()
async def remove_message(self, ctx: commands.Context, name: str, mention: str):
"""Remove custom stream alert message for already-registered streamer.
Use the command `[p]streamset message remove <streamer> <mention|nomention|both>`
Streamer must be already registered.
Command can be run by moderator.
Can only be used in server.
Note: this reverts the message for one streamer only, not all.
"""

streams_list = defaultdict(list)
guild_channels_ids = [c.id for c in ctx.guild.channels]

not_found = True
for stream in self.streams:
if stream.name.lower() == name.lower():
not_found = False
if mention == "mention":
if not hasattr(stream, "mention_message"):
break
del stream.mention_message
del stream.who_to_mention
break
elif mention == "nomention":
if not hasattr(stream, "nomention_message"):
break
del stream.nomention_message
break
elif mention == "both":
if hasattr(stream, "nomention_message"):
del stream.nomention_message
if hasattr(stream, "mention_message"):
del stream.mention_message
del stream.who_to_mention
break
else:
await ctx.send_help()

if not_found:
await ctx.send(
_("Streamer `{}` not registered. No message(s) to remove.".format(name))
)
return

await self.save_streams()
await ctx.send(_("Removed message(s) from streamer `{}`".format(name)))

@message.command(name="clear")
@commands.guild_only()
async def clear_message(self, ctx: commands.Context):
Expand Down

0 comments on commit df16ad5

Please sign in to comment.