Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for member timeouts #1902

Merged
merged 62 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
22b839b
add support for member timeouts
Nov 23, 2021
db58871
cleanup imports
Nov 23, 2021
84c5e17
fix checks
Nov 23, 2021
7e34ddc
whoops
Nov 23, 2021
5978adf
change wording
Nov 23, 2021
2269d23
change exception wording
Nov 23, 2021
34f2670
add Member#getTimeUntilTimedOut
Nov 23, 2021
6024013
add correct annotations
Nov 23, 2021
9a5a54a
remove useless import
Nov 23, 2021
faeb053
ffs
Nov 23, 2021
ba5846e
rename untimeout to removeTimeout
Nov 23, 2021
bc5c3b4
fix copy paste docs
Nov 23, 2021
089d46f
better wording
Nov 23, 2021
816e10c
add long overloads
Nov 23, 2021
5d88f62
Update src/main/java/net/dv8tion/jda/api/entities/Guild.java
Nov 23, 2021
76339dc
improve wording
Nov 23, 2021
ca92555
Merge remote-tracking branch 'origin/feature/member-timeouts' into fe…
Nov 23, 2021
a474f1f
be more concrete
Nov 23, 2021
f83ea12
add more overloads
Nov 23, 2021
87da184
remove useless imports 2: electric boogaloo
Nov 23, 2021
da4cf02
this is just dumb at this point
Nov 23, 2021
93aa099
add missing @CheckReturnValue
Nov 23, 2021
6608861
consistency
Nov 23, 2021
eb34aff
add missing check
Nov 23, 2021
2c5c179
move the impl to the interface
Nov 23, 2021
8ab767f
Merge branch 'v5' into feature/member-timeouts
Nov 28, 2021
7901270
Apply suggestions from code review
Dec 1, 2021
3ec84ec
Merge branch 'master' into feature/member-timeouts
Dec 1, 2021
bdaeb27
copyright & class level docs
Dec 1, 2021
9f0a169
add missing import
Dec 20, 2021
907e204
add params to docs
Dec 20, 2021
c20b24a
Update src/main/java/net/dv8tion/jda/api/Permission.java
Dec 20, 2021
10e7372
consistency
Dec 20, 2021
42c0b43
Merge remote-tracking branch 'origin/feature/member-timeouts' into fe…
Dec 20, 2021
0eb8749
perm fix
Dec 20, 2021
89e9991
use TemporalAccessor instead of OffsetDateTime
Dec 20, 2021
051d5a1
consistency
Dec 20, 2021
61efb5f
improvements
Dec 21, 2021
258b191
:)
Dec 21, 2021
57d689b
fix copy paste stuff
Dec 21, 2021
d5aa708
Update src/main/java/net/dv8tion/jda/api/entities/Member.java
Dec 21, 2021
73d13f4
more improvements woo
Dec 21, 2021
38d053e
Merge remote-tracking branch 'origin/feature/member-timeouts' into fe…
Dec 21, 2021
1858232
this doesn't really make sense
Dec 21, 2021
29bc229
check channel perms too
Dec 21, 2021
cf927dc
fix checks
Dec 21, 2021
8077c6e
hopefully now
Dec 21, 2021
ab6fe53
Update src/main/java/net/dv8tion/jda/api/events/guild/member/update/G…
Dec 22, 2021
29a956d
Apply suggestions from code review
Dec 22, 2021
3d6560f
add timeout AuditLogKey
Dec 27, 2021
af8aeb6
Apply suggestions from code review
Dec 27, 2021
15eaee9
Apply suggestions from code review
Dec 28, 2021
27f59bc
review changes
Dec 28, 2021
4007ad7
Merge remote-tracking branch 'origin/feature/member-timeouts' into fe…
Dec 28, 2021
c1d6043
add missing annotation
Dec 28, 2021
8366340
fix check
Dec 28, 2021
c4a1f15
move toOffsetDateTime into Helpers and add user id check
Dec 29, 2021
1bb38cc
clear up some wording
Dec 29, 2021
abb8bb7
transform max time out length into a constant
Dec 29, 2021
0619a22
generalize missing permissions
Dec 29, 2021
74d9254
Update src/main/java/net/dv8tion/jda/api/entities/Member.java
Dec 30, 2021
35ffb18
Apply suggestions from code review
Dec 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 12 additions & 48 deletions src/main/java/net/dv8tion/jda/api/EmbedBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.dv8tion.jda.api.entities.EmbedType;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.utils.TimeUtil;
import net.dv8tion.jda.internal.entities.EntityBuilder;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.Helpers;
Expand Down Expand Up @@ -72,7 +73,7 @@ public EmbedBuilder(@Nullable EmbedBuilder builder)
{
copyFrom(builder);
}

/**
* Creates an EmbedBuilder using fields in an existing embed.
*
Expand Down Expand Up @@ -257,7 +258,7 @@ public EmbedBuilder setTitle(@Nullable String title)
{
return setTitle(title, null);
}

/**
* Sets the Title of the embed.
* <br>You can provide {@code null} as url if no url should be used.
Expand Down Expand Up @@ -382,47 +383,10 @@ public EmbedBuilder appendDescription(@Nonnull CharSequence description)
@Nonnull
public EmbedBuilder setTimestamp(@Nullable TemporalAccessor temporal)
{
if (temporal == null)
{
this.timestamp = null;
}
else if (temporal instanceof OffsetDateTime)
{
this.timestamp = (OffsetDateTime) temporal;
}
else
{
ZoneOffset offset;
try
{
offset = ZoneOffset.from(temporal);
}
catch (DateTimeException ignore)
{
offset = ZoneOffset.UTC;
}
try
{
LocalDateTime ldt = LocalDateTime.from(temporal);
this.timestamp = OffsetDateTime.of(ldt, offset);
}
catch (DateTimeException ignore)
{
try
{
Instant instant = Instant.from(temporal);
this.timestamp = OffsetDateTime.ofInstant(instant, offset);
}
catch (DateTimeException ex)
{
throw new DateTimeException("Unable to obtain OffsetDateTime from TemporalAccessor: " +
temporal + " of type " + temporal.getClass().getName(), ex);
}
}
}
return this;
this.timestamp = TimeUtil.toOffsetDateTime(temporal);
return this;
}

/**
* Sets the Color of the embed.
*
Expand Down Expand Up @@ -461,7 +425,7 @@ public EmbedBuilder setColor(int color)
this.color = color;
return this;
}

/**
* Sets the Thumbnail of the embed.
*
Expand Down Expand Up @@ -557,7 +521,7 @@ public EmbedBuilder setImage(@Nullable String url)
}
return this;
}

/**
* Sets the Author of the embed. The author appears in the top left of the embed and can have a small
* image beside it along with the author's name being made clickable by way of providing a url.
Expand Down Expand Up @@ -747,7 +711,7 @@ public EmbedBuilder setFooter(@Nullable String text, @Nullable String iconUrl)
/**
* Copies the provided Field into a new Field for this builder.
* <br>For additional documentation, see {@link #addField(String, String, boolean)}
*
*
* @param field
* the field object to add
*
Expand All @@ -758,7 +722,7 @@ public EmbedBuilder addField(@Nullable MessageEmbed.Field field)
{
return field == null ? this : addField(field.getName(), field.getValue(), field.isInline());
}

/**
* Adds a Field to the embed.
*
Expand Down Expand Up @@ -794,7 +758,7 @@ public EmbedBuilder addField(@Nullable String name, @Nullable String value, bool
this.fields.add(new MessageEmbed.Field(name, value, inline));
return this;
}

/**
* Adds a blank (empty) Field to the embed.
*
Expand Down Expand Up @@ -827,7 +791,7 @@ public EmbedBuilder clearFields()
this.fields.clear();
return this;
}

/**
* <b>Modifiable</b> list of {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbed} Fields that the builder will
* use for {@link #build()}.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/dv8tion/jda/api/Permission.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum Permission
BAN_MEMBERS( 2, true, false, "Ban Members"),
NICKNAME_CHANGE( 26, true, false, "Change Nickname"),
NICKNAME_MANAGE( 27, true, false, "Manage Nicknames"),
MODERATE_MEMBERS( 40, true, false, "Timeout Members"),

// Text Permissions
MESSAGE_ADD_REACTION( 6, true, true, "Add Reactions"),
Expand Down
Loading