Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Commit 44d4213

Browse files
committed
Fix ephemeral responses
1 parent 77eac73 commit 44d4213

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

TabletBot.Discord/SlashCommands/ModerationSlashCommands.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ protected override IEnumerable<SlashCommand> GetSlashCommands()
2121
{
2222
Name = DELETE,
2323
Handler = Delete,
24+
Ephemeral = true,
2425
MinimumPermissions = GuildPermissions.None.Modify(
2526
manageMessages: true
2627
),
@@ -45,6 +46,7 @@ protected override IEnumerable<SlashCommand> GetSlashCommands()
4546
{
4647
Name = KICK_USER,
4748
Handler = Kick,
49+
Ephemeral = true,
4850
MinimumPermissions = GuildPermissions.None.Modify(
4951
kickMembers: true
5052
),
@@ -76,6 +78,7 @@ protected override IEnumerable<SlashCommand> GetSlashCommands()
7678
{
7779
Name = BAN_USER,
7880
Handler = Ban,
81+
Ephemeral = true,
7982
MinimumPermissions = GuildPermissions.None.Modify(
8083
banMembers: true
8184
),
@@ -107,6 +110,7 @@ protected override IEnumerable<SlashCommand> GetSlashCommands()
107110
{
108111
Name = CREATE_EMBED,
109112
Handler = CreateEmbed,
113+
Ephemeral = false,
110114
MinimumPermissions = GuildPermissions.None.Modify(
111115
sendTTSMessages: true
112116
),
@@ -169,7 +173,7 @@ private async Task Delete(SocketSlashCommand command)
169173

170174
var messages = await command.Channel.GetMessagesAsync(amount).FlattenAsync();
171175
await (command.Channel as ITextChannel).DeleteMessagesAsync(messages);
172-
await command.FollowupAsync($"Deleted {amount} messages.", ephemeral: true);
176+
await command.FollowupAsync($"Deleted {amount} messages.");
173177
}
174178

175179
private async Task Kick(SocketSlashCommand command)
@@ -181,16 +185,13 @@ private async Task Kick(SocketSlashCommand command)
181185
{
182186
await user.KickAsync(reason);
183187
if (reason != null)
184-
await command.FollowupAsync($"Kicked {user.Mention} for \"{reason}\".", ephemeral: true);
188+
await command.FollowupAsync($"Kicked {user.Mention} for \"{reason}\".");
185189
else
186-
await command.FollowupAsync($"Kicked {user.Mention}.", ephemeral: true);
190+
await command.FollowupAsync($"Kicked {user.Mention}.");
187191
}
188192
else
189193
{
190-
await command.FollowupAsync(
191-
$"This user is not a member of this guild.",
192-
ephemeral: true
193-
);
194+
await command.FollowupAsync("This user is not a member of this guild.");
194195
}
195196
}
196197

@@ -205,16 +206,13 @@ private async Task Ban(SocketSlashCommand command)
205206
{
206207
await user.BanAsync(reason: reason);
207208
if (reason != null)
208-
await command.FollowupAsync($"Banned {user.Mention} for \"{reason}\".", ephemeral: true);
209+
await command.FollowupAsync($"Banned {user.Mention} for \"{reason}\".");
209210
else
210-
await command.FollowupAsync($"Banned {user.Mention}.", ephemeral: true);
211+
await command.FollowupAsync($"Banned {user.Mention}.");
211212
}
212213
else
213214
{
214-
await command.FollowupAsync(
215-
$"This user is not a member of this guild.",
216-
ephemeral: true
217-
);
215+
await command.FollowupAsync("This user is not a member of this guild.");
218216
}
219217
}
220218

TabletBot.Discord/SlashCommands/SlashCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ public class SlashCommand
1212
public SlashCommandBuilder Builder { set; get; }
1313
public Func<SocketSlashCommand, Task> Handler { set; get; }
1414
public GuildPermissions? MinimumPermissions { set; get; }
15+
public bool Ephemeral { set; get; }
1516

1617
public SlashCommandProperties Build() => Builder.Build();
1718

1819
public async Task Invoke(SocketSlashCommand command)
1920
{
20-
await command.DeferAsync(true);
21+
await command.DeferAsync(Ephemeral);
2122
if (MinimumPermissions is GuildPermissions permissions)
2223
{
2324
var user = command.User as IGuildUser;
@@ -27,7 +28,7 @@ public async Task Invoke(SocketSlashCommand command)
2728
}
2829
else
2930
{
30-
await command.FollowupAsync("You do not have permissions to use this command.", ephemeral: true);
31+
await command.FollowupAsync("You do not have permissions to use this command.");
3132
}
3233
}
3334
else

TabletBot.Discord/SlashCommands/SnippetSlashCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private async Task ShowSnippet(SocketSlashCommand command)
144144
var snippet = command.GetValue<string>("snippet");
145145

146146
if (SnippetEmbeds.TryGetSnippetEmbed(_settings, snippet, out var embed))
147-
await command.FollowupAsync(embed: embed.Build());
147+
await command.FollowupAsync(embed: embed.Build(), ephemeral: false);
148148
else
149149
await command.FollowupAsync("Could not find snippet");
150150
}

TabletBot.Discord/SlashCommands/UserSlashCommands.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ protected override IEnumerable<SlashCommand> GetSlashCommands()
1616
{
1717
Name = SET_TABLET,
1818
Handler = SetTablet,
19+
Ephemeral = true,
1920
Builder = new SlashCommandBuilder
2021
{
2122
Name = SET_TABLET,
@@ -42,12 +43,12 @@ private async Task SetTablet(SocketSlashCommand command)
4243
if (tablet != null)
4344
{
4445
await user.ModifyAsync(u => u.Nickname = $"{user.Username} | {tablet}");
45-
await command.FollowupAsync($"Your nickname has updated to include your tablet.", ephemeral: true);
46+
await command.FollowupAsync($"Your nickname has updated to include your tablet.");
4647
}
4748
else
4849
{
4950
await user.ModifyAsync(u => u.Nickname = null);
50-
await command.FollowupAsync($"Your nickname has been reset.", ephemeral: true);
51+
await command.FollowupAsync($"Your nickname has been reset.");
5152
}
5253
}
5354
}

0 commit comments

Comments
 (0)