Skip to content

Commit

Permalink
View timeout for config
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Feb 23, 2024
1 parent ab8d057 commit 9dc1d98
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions Cogs/Configuration/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ async def callback(self, interaction: discord.Interaction):
view = StaffDB(self.author)
embed.set_thumbnail(url=interaction.guild.icon)
embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon)
await interaction.edit_original_response(embed=embed, view=view)
view.message = await interaction.edit_original_response(embed=embed, view=view)


class StaffDB(discord.ui.View):
Expand All @@ -600,13 +600,18 @@ def __init__(self, author):
self.add_item(StaffCustomise(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class ConfigViewMain(discord.ui.View):
def __init__(self, author):
super().__init__(timeout=360)
self.add_item(StaffRole(author))
self.add_item(Adminrole(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class SuggestionModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -625,6 +630,8 @@ def __init__(self, author):
self.add_item(CreateButtons(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class Modmail(discord.ui.View):
def __init__(self, author):
Expand All @@ -635,6 +642,8 @@ def __init__(self, author):
self.add_item(TranscriptChannel(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class InfractModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -645,6 +654,8 @@ def __init__(self, author):
self.add_item(InfractionTypes(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class UtilsModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -653,7 +664,8 @@ def __init__(self, author):
self.add_item(ToggleUtils(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class PromotionModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -663,7 +675,8 @@ def __init__(self, author):
self.add_item(PromotionModuleToggle(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class LOAModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -673,14 +686,17 @@ def __init__(self, author):
self.add_item(ToggleLOADropdown(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class TagsModule(discord.ui.View):
def __init__(self, author):
super().__init__(timeout=360)
self.add_item(ToggleTags(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class QuotaModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -689,6 +705,8 @@ def __init__(self, author):
self.add_item(QuotaToggle(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class FeedbackModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -697,15 +715,17 @@ def __init__(self, author):
self.add_item(ToggleFeedback(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class SuspensionsModule(discord.ui.View):
def __init__(self, author):
super().__init__(timeout=360)
self.add_item(ToggleSuspensions(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class PartnershipModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -714,14 +734,17 @@ def __init__(self, author):
self.add_item(TogglePartnerships(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class ForumUtilsModule(discord.ui.View):
def __init__(self, author):
super().__init__(timeout=360)
self.add_item(ToggleForums(author))
self.add_item(Config(author))

async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class ReportsModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -731,7 +754,8 @@ def __init__(self, author):
self.add_item(ToggleReportsDropdown(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class AppResultModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -741,15 +765,17 @@ def __init__(self, author):
self.add_item(ToggleApplications(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class ConnectionsModule(discord.ui.View):
def __init__(self, author):
super().__init__(timeout=360)
self.add_item(ToggleConnectionRoles(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class CustomisatiomModule(discord.ui.View):
def __init__(self, author):
Expand All @@ -758,7 +784,8 @@ def __init__(self, author):
self.add_item(ResetEmbeds(author))
self.add_item(Config(author))


async def on_timeout(self) -> None:
await self.message.edit(view=None, embed=None, content=f"{no} **Timed out**")

class ConfigCog(commands.Cog):
def __init__(self, client: commands.Bot):
Expand Down Expand Up @@ -811,7 +838,7 @@ async def config(self, ctx):
embed.set_thumbnail(url=ctx.guild.icon)
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon)
view = ConfigViewMain(ctx.author)
await ctx.send(embed=embed, view=view)
view.message = await ctx.send(embed=embed, view=view)

@config.error
async def permissionerror(self, ctx, error):
Expand Down

0 comments on commit 9dc1d98

Please sign in to comment.